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 bn_field_sub: #t:limb_t -> km:BM.mont t -> bn_field_sub_st t km.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Bignum.Lib", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_field_sub #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.sub_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
val bn_field_sub: #t:limb_t -> km:BM.mont t -> bn_field_sub_st t km.BM.bn.BN.len let bn_field_sub #t km k aM bM cM =
false
null
false
let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.sub_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
{ "checked_file": "Hacl.Bignum.MontArithmetic.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontExponentiation.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.MontArithmetic.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Prims._assert", "Prims.eq2", "Lib.Sequence.seq", "Hacl.Bignum.Definitions.limb", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.l_and", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Spec.Bignum.MontArithmetic.bn_field_sub", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.__proj__Mkbn__item__sub_mod_n", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder" ]
[]
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.MontArithmetic module BD = Hacl.Spec.Bignum.Definitions module BB = Hacl.Bignum.Base module BL = Hacl.Bignum.Lib module ME = Hacl.Bignum.MontExponentiation module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module BI = Hacl.Bignum.ModInv friend Hacl.Spec.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let _align_fsti = () let bn_field_get_len #t k = let open LowStar.BufferOps in let k1 = !*k in k1.len let bn_field_check_modulus #t km n = let m = km.BM.mont_check n in BB.unsafe_bool_of_limb m let bn_field_init #t len precomp_r2 r n = let h0 = ST.get () in let r2 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let n1 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let h1 = ST.get () in B.(modifies_only_not_unused_in loc_none h0 h1); assert (B.length r2 == FStar.UInt32.v len); assert (B.length n1 == FStar.UInt32.v len); let r2 : lbignum t len = r2 in let n1 : lbignum t len = n1 in copy n1 n; let nBits = size (bits t) *! BB.unsafe_size_from_limb (BL.bn_get_top_index len n) in precomp_r2 nBits n r2; let mu = BM.mod_inv_limb n.(0ul) in let res : bn_mont_ctx t = { len = len; n = n1; mu = mu; r2 = r2 } in let h2 = ST.get () in assert (as_ctx h2 res == S.bn_field_init (as_seq h0 n)); assert (S.bn_mont_ctx_inv (as_ctx h2 res)); B.(modifies_only_not_unused_in loc_none h0 h2); B.malloc r res 1ul let bn_field_free #t k = let open LowStar.BufferOps in let k1 = !*k in let n : buffer (limb t) = k1.n in let r2 : buffer (limb t) = k1.r2 in B.free n; B.freeable_disjoint n r2; B.free r2; B.free k let bn_to_field #t km k a aM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.to k1.n k1.mu k1.r2 a aM; let h1 = ST.get () in assert (as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) let bn_from_field #t km k aM a = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.from k1.n k1.mu aM a; let h1 = ST.get () in assert (as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) let bn_field_add #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.add_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
false
false
Hacl.Bignum.MontArithmetic.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 bn_field_sub: #t:limb_t -> km:BM.mont t -> bn_field_sub_st t km.BM.bn.BN.len
[]
Hacl.Bignum.MontArithmetic.bn_field_sub
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
km: Hacl.Bignum.Montgomery.mont t -> Hacl.Bignum.MontArithmetic.bn_field_sub_st t (Mkbn?.len (Mkmont?.bn km))
{ "end_col": 86, "end_line": 112, "start_col": 2, "start_line": 107 }
Prims.Tot
val bn_field_add: #t:limb_t -> km:BM.mont t -> bn_field_add_st t km.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Bignum.Lib", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_field_add #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.add_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
val bn_field_add: #t:limb_t -> km:BM.mont t -> bn_field_add_st t km.BM.bn.BN.len let bn_field_add #t km k aM bM cM =
false
null
false
let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.add_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
{ "checked_file": "Hacl.Bignum.MontArithmetic.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontExponentiation.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.MontArithmetic.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Prims._assert", "Prims.eq2", "Lib.Sequence.seq", "Hacl.Bignum.Definitions.limb", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.l_and", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Spec.Bignum.MontArithmetic.bn_field_add", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.__proj__Mkbn__item__add_mod_n", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder" ]
[]
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.MontArithmetic module BD = Hacl.Spec.Bignum.Definitions module BB = Hacl.Bignum.Base module BL = Hacl.Bignum.Lib module ME = Hacl.Bignum.MontExponentiation module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module BI = Hacl.Bignum.ModInv friend Hacl.Spec.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let _align_fsti = () let bn_field_get_len #t k = let open LowStar.BufferOps in let k1 = !*k in k1.len let bn_field_check_modulus #t km n = let m = km.BM.mont_check n in BB.unsafe_bool_of_limb m let bn_field_init #t len precomp_r2 r n = let h0 = ST.get () in let r2 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let n1 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let h1 = ST.get () in B.(modifies_only_not_unused_in loc_none h0 h1); assert (B.length r2 == FStar.UInt32.v len); assert (B.length n1 == FStar.UInt32.v len); let r2 : lbignum t len = r2 in let n1 : lbignum t len = n1 in copy n1 n; let nBits = size (bits t) *! BB.unsafe_size_from_limb (BL.bn_get_top_index len n) in precomp_r2 nBits n r2; let mu = BM.mod_inv_limb n.(0ul) in let res : bn_mont_ctx t = { len = len; n = n1; mu = mu; r2 = r2 } in let h2 = ST.get () in assert (as_ctx h2 res == S.bn_field_init (as_seq h0 n)); assert (S.bn_mont_ctx_inv (as_ctx h2 res)); B.(modifies_only_not_unused_in loc_none h0 h2); B.malloc r res 1ul let bn_field_free #t k = let open LowStar.BufferOps in let k1 = !*k in let n : buffer (limb t) = k1.n in let r2 : buffer (limb t) = k1.r2 in B.free n; B.freeable_disjoint n r2; B.free r2; B.free k let bn_to_field #t km k a aM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.to k1.n k1.mu k1.r2 a aM; let h1 = ST.get () in assert (as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) let bn_from_field #t km k aM a = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.from k1.n k1.mu aM a; let h1 = ST.get () in assert (as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM))
false
false
Hacl.Bignum.MontArithmetic.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 bn_field_add: #t:limb_t -> km:BM.mont t -> bn_field_add_st t km.BM.bn.BN.len
[]
Hacl.Bignum.MontArithmetic.bn_field_add
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
km: Hacl.Bignum.Montgomery.mont t -> Hacl.Bignum.MontArithmetic.bn_field_add_st t (Mkbn?.len (Mkmont?.bn km))
{ "end_col": 86, "end_line": 103, "start_col": 2, "start_line": 98 }
Prims.Tot
val bn_field_mul: #t:limb_t -> km:BM.mont t -> bn_field_mul_st t km.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Bignum.Lib", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_field_mul #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.mul k1.n k1.mu aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_mul (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
val bn_field_mul: #t:limb_t -> km:BM.mont t -> bn_field_mul_st t km.BM.bn.BN.len let bn_field_mul #t km k aM bM cM =
false
null
false
let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.mul k1.n k1.mu aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_mul (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
{ "checked_file": "Hacl.Bignum.MontArithmetic.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontExponentiation.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.MontArithmetic.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Prims._assert", "Prims.eq2", "Lib.Sequence.seq", "Hacl.Bignum.Definitions.limb", "Prims.l_or", "Prims.nat", "FStar.Seq.Base.length", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.l_and", "Hacl.Spec.Bignum.Definitions.limb", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__len", "Hacl.Bignum.MontArithmetic.as_pctx", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Hacl.Spec.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx__item__n", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Spec.Bignum.MontArithmetic.bn_field_mul", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__mul", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__mu", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder" ]
[]
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.MontArithmetic module BD = Hacl.Spec.Bignum.Definitions module BB = Hacl.Bignum.Base module BL = Hacl.Bignum.Lib module ME = Hacl.Bignum.MontExponentiation module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module BI = Hacl.Bignum.ModInv friend Hacl.Spec.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let _align_fsti = () let bn_field_get_len #t k = let open LowStar.BufferOps in let k1 = !*k in k1.len let bn_field_check_modulus #t km n = let m = km.BM.mont_check n in BB.unsafe_bool_of_limb m let bn_field_init #t len precomp_r2 r n = let h0 = ST.get () in let r2 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let n1 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let h1 = ST.get () in B.(modifies_only_not_unused_in loc_none h0 h1); assert (B.length r2 == FStar.UInt32.v len); assert (B.length n1 == FStar.UInt32.v len); let r2 : lbignum t len = r2 in let n1 : lbignum t len = n1 in copy n1 n; let nBits = size (bits t) *! BB.unsafe_size_from_limb (BL.bn_get_top_index len n) in precomp_r2 nBits n r2; let mu = BM.mod_inv_limb n.(0ul) in let res : bn_mont_ctx t = { len = len; n = n1; mu = mu; r2 = r2 } in let h2 = ST.get () in assert (as_ctx h2 res == S.bn_field_init (as_seq h0 n)); assert (S.bn_mont_ctx_inv (as_ctx h2 res)); B.(modifies_only_not_unused_in loc_none h0 h2); B.malloc r res 1ul let bn_field_free #t k = let open LowStar.BufferOps in let k1 = !*k in let n : buffer (limb t) = k1.n in let r2 : buffer (limb t) = k1.r2 in B.free n; B.freeable_disjoint n r2; B.free r2; B.free k let bn_to_field #t km k a aM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.to k1.n k1.mu k1.r2 a aM; let h1 = ST.get () in assert (as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) let bn_from_field #t km k aM a = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.from k1.n k1.mu aM a; let h1 = ST.get () in assert (as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) let bn_field_add #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.add_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_sub #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.sub_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM))
false
false
Hacl.Bignum.MontArithmetic.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 bn_field_mul: #t:limb_t -> km:BM.mont t -> bn_field_mul_st t km.BM.bn.BN.len
[]
Hacl.Bignum.MontArithmetic.bn_field_mul
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
km: Hacl.Bignum.Montgomery.mont t -> Hacl.Bignum.MontArithmetic.bn_field_mul_st t (Mkbn?.len (Mkmont?.bn km))
{ "end_col": 86, "end_line": 121, "start_col": 2, "start_line": 116 }
Prims.Tot
val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Bignum.Lib", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_field_init #t len precomp_r2 r n = let h0 = ST.get () in let r2 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let n1 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let h1 = ST.get () in B.(modifies_only_not_unused_in loc_none h0 h1); assert (B.length r2 == FStar.UInt32.v len); assert (B.length n1 == FStar.UInt32.v len); let r2 : lbignum t len = r2 in let n1 : lbignum t len = n1 in copy n1 n; let nBits = size (bits t) *! BB.unsafe_size_from_limb (BL.bn_get_top_index len n) in precomp_r2 nBits n r2; let mu = BM.mod_inv_limb n.(0ul) in let res : bn_mont_ctx t = { len = len; n = n1; mu = mu; r2 = r2 } in let h2 = ST.get () in assert (as_ctx h2 res == S.bn_field_init (as_seq h0 n)); assert (S.bn_mont_ctx_inv (as_ctx h2 res)); B.(modifies_only_not_unused_in loc_none h0 h2); B.malloc r res 1ul
val bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len let bn_field_init #t len precomp_r2 r n =
false
null
false
let h0 = ST.get () in let r2:buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let n1:buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let h1 = ST.get () in (let open B in modifies_only_not_unused_in loc_none h0 h1); assert (B.length r2 == FStar.UInt32.v len); assert (B.length n1 == FStar.UInt32.v len); let r2:lbignum t len = r2 in let n1:lbignum t len = n1 in copy n1 n; let nBits = size (bits t) *! BB.unsafe_size_from_limb (BL.bn_get_top_index len n) in precomp_r2 nBits n r2; let mu = BM.mod_inv_limb n.(0ul) in let res:bn_mont_ctx t = { len = len; n = n1; mu = mu; r2 = r2 } in let h2 = ST.get () in assert (as_ctx h2 res == S.bn_field_init (as_seq h0 n)); assert (S.bn_mont_ctx_inv (as_ctx h2 res)); (let open B in modifies_only_not_unused_in loc_none h0 h2); B.malloc r res 1ul
{ "checked_file": "Hacl.Bignum.MontArithmetic.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontExponentiation.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.MontArithmetic.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.meta_len", "Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st", "FStar.Monotonic.HyperHeap.rid", "Hacl.Bignum.Definitions.lbignum", "LowStar.Buffer.malloc", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "FStar.UInt32.__uint_to_t", "LowStar.Monotonic.Buffer.mbuffer", "LowStar.Buffer.trivial_preorder", "Prims.l_and", "Prims.eq2", "Prims.nat", "LowStar.Monotonic.Buffer.length", "FStar.UInt32.v", "Prims.b2t", "Prims.op_Negation", "LowStar.Monotonic.Buffer.g_is_null", "LowStar.Monotonic.Buffer.frameOf", "LowStar.Monotonic.Buffer.freeable", "Prims.unit", "LowStar.Monotonic.Buffer.modifies_only_not_unused_in", "LowStar.Monotonic.Buffer.loc_none", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Prims._assert", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx_inv", "Hacl.Bignum.MontArithmetic.as_ctx", "Hacl.Spec.Bignum.MontArithmetic.bn_mont_ctx", "Hacl.Spec.Bignum.MontArithmetic.bn_field_init", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.MontArithmetic.Mkbn_mont_ctx'", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Bignum.ModInvLimb.mod_inv_limb", "Lib.Buffer.op_Array_Access", "Lib.IntTypes.int_t", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Lib.IntTypes.range", "Prims.op_Multiply", "Lib.IntTypes.mk_int", "Hacl.Spec.Bignum.Base.unsafe_size_from_limb", "Hacl.Spec.Bignum.Definitions.limb", "Prims.op_LessThanOrEqual", "Lib.IntTypes.SEC", "Prims.op_Subtraction", "Prims.pow2", "Hacl.Bignum.Lib.bn_get_top_index", "Lib.Buffer.copy", "Prims.int", "Prims.l_or", "FStar.UInt.size", "FStar.UInt32.n", "Prims.op_GreaterThanOrEqual", "Lib.Buffer.buffer_t", "LowStar.Monotonic.Buffer.mmalloc", "Lib.IntTypes.uint", "LowStar.Monotonic.Buffer.lmbuffer" ]
[]
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.MontArithmetic module BD = Hacl.Spec.Bignum.Definitions module BB = Hacl.Bignum.Base module BL = Hacl.Bignum.Lib module ME = Hacl.Bignum.MontExponentiation module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module BI = Hacl.Bignum.ModInv friend Hacl.Spec.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let _align_fsti = () let bn_field_get_len #t k = let open LowStar.BufferOps in let k1 = !*k in k1.len let bn_field_check_modulus #t km n = let m = km.BM.mont_check n in BB.unsafe_bool_of_limb m
false
false
Hacl.Bignum.MontArithmetic.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 bn_field_init: #t:limb_t -> len:BN.meta_len t -> precomp_r2:BM.bn_precomp_r2_mod_n_st t len -> bn_field_init_st t len
[]
Hacl.Bignum.MontArithmetic.bn_field_init
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Hacl.Bignum.meta_len t -> precomp_r2: Hacl.Bignum.Montgomery.bn_precomp_r2_mod_n_st t len -> Hacl.Bignum.MontArithmetic.bn_field_init_st t len
{ "end_col": 20, "end_line": 65, "start_col": 41, "start_line": 44 }
Prims.Tot
val bn_field_inv: #t:limb_t -> len:Ghost.erased _ -> bn_field_exp_vartime:bn_field_exp_vartime_st t len -> bn_field_inv_st t len
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Bignum.Lib", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_field_inv #t len bn_field_exp_vartime k aM aInvM = let open LowStar.BufferOps in let k1 = !*k in let len = k1.len in push_frame (); let n2 = create len (uint #t #SEC 0) in BI.bn_mod_inv_prime_n2 len k1.n n2; bn_field_exp_vartime k aM (k1.len *! size (bits t)) n2 aInvM; pop_frame ()
val bn_field_inv: #t:limb_t -> len:Ghost.erased _ -> bn_field_exp_vartime:bn_field_exp_vartime_st t len -> bn_field_inv_st t len let bn_field_inv #t len bn_field_exp_vartime k aM aInvM =
false
null
false
let open LowStar.BufferOps in let k1 = !*k in let len = k1.len in push_frame (); let n2 = create len (uint #t #SEC 0) in BI.bn_mod_inv_prime_n2 len k1.n n2; bn_field_exp_vartime k aM (k1.len *! size (bits t)) n2 aInvM; pop_frame ()
{ "checked_file": "Hacl.Bignum.MontArithmetic.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontExponentiation.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.MontArithmetic.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "FStar.Ghost.erased", "Hacl.Bignum.meta_len", "Hacl.Bignum.MontArithmetic.bn_field_exp_vartime_st", "FStar.Ghost.reveal", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Lib.IntTypes.size", "Lib.IntTypes.bits", "Hacl.Bignum.ModInv.bn_mod_inv_prime_n2", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder" ]
[]
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.MontArithmetic module BD = Hacl.Spec.Bignum.Definitions module BB = Hacl.Bignum.Base module BL = Hacl.Bignum.Lib module ME = Hacl.Bignum.MontExponentiation module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module BI = Hacl.Bignum.ModInv friend Hacl.Spec.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let _align_fsti = () let bn_field_get_len #t k = let open LowStar.BufferOps in let k1 = !*k in k1.len let bn_field_check_modulus #t km n = let m = km.BM.mont_check n in BB.unsafe_bool_of_limb m let bn_field_init #t len precomp_r2 r n = let h0 = ST.get () in let r2 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let n1 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let h1 = ST.get () in B.(modifies_only_not_unused_in loc_none h0 h1); assert (B.length r2 == FStar.UInt32.v len); assert (B.length n1 == FStar.UInt32.v len); let r2 : lbignum t len = r2 in let n1 : lbignum t len = n1 in copy n1 n; let nBits = size (bits t) *! BB.unsafe_size_from_limb (BL.bn_get_top_index len n) in precomp_r2 nBits n r2; let mu = BM.mod_inv_limb n.(0ul) in let res : bn_mont_ctx t = { len = len; n = n1; mu = mu; r2 = r2 } in let h2 = ST.get () in assert (as_ctx h2 res == S.bn_field_init (as_seq h0 n)); assert (S.bn_mont_ctx_inv (as_ctx h2 res)); B.(modifies_only_not_unused_in loc_none h0 h2); B.malloc r res 1ul let bn_field_free #t k = let open LowStar.BufferOps in let k1 = !*k in let n : buffer (limb t) = k1.n in let r2 : buffer (limb t) = k1.r2 in B.free n; B.freeable_disjoint n r2; B.free r2; B.free k let bn_to_field #t km k a aM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.to k1.n k1.mu k1.r2 a aM; let h1 = ST.get () in assert (as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) let bn_from_field #t km k aM a = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.from k1.n k1.mu aM a; let h1 = ST.get () in assert (as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) let bn_field_add #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.add_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_sub #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.sub_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_mul #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.mul k1.n k1.mu aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_mul (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_sqr #t km k aM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.sqr k1.n k1.mu aM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_sqr (as_pctx h0 k) (as_seq h0 aM)) let bn_field_one #t km k oneM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in BM.bn_mont_one km.BM.bn.BN.len km.BM.from k1.n k1.mu k1.r2 oneM; let h1 = ST.get () in assert (as_seq h1 oneM == S.bn_field_one (as_pctx h0 k)) let bn_field_exp_consttime #t km k aM bBits b resM = let open LowStar.BufferOps in let k1 = !*k in push_frame (); let aMc = create k1.len (uint #t #SEC 0) in copy aMc aM; ME.bn_exp_mont_consttime #t km k1.n k1.mu k1.r2 aMc bBits b resM; let h0 = ST.get () in assert (bn_v h0 aM < bn_v_n h0 k); BD.bn_eval_inj (v k1.len) (S.bn_field_exp_consttime (as_pctx h0 k) (as_seq h0 aM) (v bBits) (as_seq h0 b)) (as_seq h0 resM); pop_frame () let bn_field_exp_vartime #t km k aM bBits b resM = let open LowStar.BufferOps in let k1 = !*k in push_frame (); let aMc = create k1.len (uint #t #SEC 0) in copy aMc aM; ME.bn_exp_mont_vartime #t km k1.n k1.mu k1.r2 aMc bBits b resM; let h0 = ST.get () in assert (bn_v h0 aM < bn_v_n h0 k); BD.bn_eval_inj (v k1.len) (S.bn_field_exp_vartime (as_pctx h0 k) (as_seq h0 aM) (v bBits) (as_seq h0 b)) (as_seq h0 resM); pop_frame ()
false
false
Hacl.Bignum.MontArithmetic.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 bn_field_inv: #t:limb_t -> len:Ghost.erased _ -> bn_field_exp_vartime:bn_field_exp_vartime_st t len -> bn_field_inv_st t len
[]
Hacl.Bignum.MontArithmetic.bn_field_inv
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: FStar.Ghost.erased (Hacl.Bignum.meta_len t) -> bn_field_exp_vartime: Hacl.Bignum.MontArithmetic.bn_field_exp_vartime_st t (FStar.Ghost.reveal len) -> Hacl.Bignum.MontArithmetic.bn_field_inv_st t (FStar.Ghost.reveal len)
{ "end_col": 14, "end_line": 180, "start_col": 2, "start_line": 173 }
Prims.Tot
val bn_field_exp_consttime: #t:limb_t -> km:BM.mont t -> bn_field_exp_consttime_st t km.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Bignum.Lib", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_field_exp_consttime #t km k aM bBits b resM = let open LowStar.BufferOps in let k1 = !*k in push_frame (); let aMc = create k1.len (uint #t #SEC 0) in copy aMc aM; ME.bn_exp_mont_consttime #t km k1.n k1.mu k1.r2 aMc bBits b resM; let h0 = ST.get () in assert (bn_v h0 aM < bn_v_n h0 k); BD.bn_eval_inj (v k1.len) (S.bn_field_exp_consttime (as_pctx h0 k) (as_seq h0 aM) (v bBits) (as_seq h0 b)) (as_seq h0 resM); pop_frame ()
val bn_field_exp_consttime: #t:limb_t -> km:BM.mont t -> bn_field_exp_consttime_st t km.BM.bn.BN.len let bn_field_exp_consttime #t km k aM bBits b resM =
false
null
false
let open LowStar.BufferOps in let k1 = !*k in push_frame (); let aMc = create k1.len (uint #t #SEC 0) in copy aMc aM; ME.bn_exp_mont_consttime #t km k1.n k1.mu k1.r2 aMc bBits b resM; let h0 = ST.get () in assert (bn_v h0 aM < bn_v_n h0 k); BD.bn_eval_inj (v k1.len) (S.bn_field_exp_consttime (as_pctx h0 k) (as_seq h0 aM) (v bBits) (as_seq h0 b)) (as_seq h0 resM); pop_frame ()
{ "checked_file": "Hacl.Bignum.MontArithmetic.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontExponentiation.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.MontArithmetic.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.Bignum.Definitions.bn_eval_inj", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Spec.Bignum.MontArithmetic.bn_field_exp_consttime", "Hacl.Bignum.MontArithmetic.as_pctx", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Prims._assert", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Definitions.bn_v", "Hacl.Bignum.MontArithmetic.bn_v_n", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.MontExponentiation.bn_exp_mont_consttime", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__mu", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__r2", "Lib.Buffer.copy", "Lib.Buffer.lbuffer_t", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder" ]
[]
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.MontArithmetic module BD = Hacl.Spec.Bignum.Definitions module BB = Hacl.Bignum.Base module BL = Hacl.Bignum.Lib module ME = Hacl.Bignum.MontExponentiation module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module BI = Hacl.Bignum.ModInv friend Hacl.Spec.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let _align_fsti = () let bn_field_get_len #t k = let open LowStar.BufferOps in let k1 = !*k in k1.len let bn_field_check_modulus #t km n = let m = km.BM.mont_check n in BB.unsafe_bool_of_limb m let bn_field_init #t len precomp_r2 r n = let h0 = ST.get () in let r2 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let n1 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let h1 = ST.get () in B.(modifies_only_not_unused_in loc_none h0 h1); assert (B.length r2 == FStar.UInt32.v len); assert (B.length n1 == FStar.UInt32.v len); let r2 : lbignum t len = r2 in let n1 : lbignum t len = n1 in copy n1 n; let nBits = size (bits t) *! BB.unsafe_size_from_limb (BL.bn_get_top_index len n) in precomp_r2 nBits n r2; let mu = BM.mod_inv_limb n.(0ul) in let res : bn_mont_ctx t = { len = len; n = n1; mu = mu; r2 = r2 } in let h2 = ST.get () in assert (as_ctx h2 res == S.bn_field_init (as_seq h0 n)); assert (S.bn_mont_ctx_inv (as_ctx h2 res)); B.(modifies_only_not_unused_in loc_none h0 h2); B.malloc r res 1ul let bn_field_free #t k = let open LowStar.BufferOps in let k1 = !*k in let n : buffer (limb t) = k1.n in let r2 : buffer (limb t) = k1.r2 in B.free n; B.freeable_disjoint n r2; B.free r2; B.free k let bn_to_field #t km k a aM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.to k1.n k1.mu k1.r2 a aM; let h1 = ST.get () in assert (as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) let bn_from_field #t km k aM a = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.from k1.n k1.mu aM a; let h1 = ST.get () in assert (as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) let bn_field_add #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.add_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_sub #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.sub_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_mul #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.mul k1.n k1.mu aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_mul (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_sqr #t km k aM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.sqr k1.n k1.mu aM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_sqr (as_pctx h0 k) (as_seq h0 aM)) let bn_field_one #t km k oneM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in BM.bn_mont_one km.BM.bn.BN.len km.BM.from k1.n k1.mu k1.r2 oneM; let h1 = ST.get () in assert (as_seq h1 oneM == S.bn_field_one (as_pctx h0 k))
false
false
Hacl.Bignum.MontArithmetic.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 bn_field_exp_consttime: #t:limb_t -> km:BM.mont t -> bn_field_exp_consttime_st t km.BM.bn.BN.len
[]
Hacl.Bignum.MontArithmetic.bn_field_exp_consttime
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
km: Hacl.Bignum.Montgomery.mont t -> Hacl.Bignum.MontArithmetic.bn_field_exp_consttime_st t (Mkbn?.len (Mkmont?.bn km))
{ "end_col": 14, "end_line": 154, "start_col": 2, "start_line": 143 }
Prims.Tot
val bn_field_exp_vartime: #t:limb_t -> km:BM.mont t -> bn_field_exp_vartime_st t km.BM.bn.BN.len
[ { "abbrev": true, "full_module": "Hacl.Bignum.ModInv", "short_module": "BI" }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Bignum.MontExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Bignum.Lib", "short_module": "BL" }, { "abbrev": true, "full_module": "Hacl.Bignum.Base", "short_module": "BB" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Bignum.Montgomery", "short_module": "BM" }, { "abbrev": true, "full_module": "Hacl.Bignum", "short_module": "BN" }, { "abbrev": true, "full_module": "Hacl.Bignum.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.MontArithmetic", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.Math.Euclid", "short_module": "Euclid" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": true, "full_module": "LowStar.Buffer", "short_module": "B" }, { "abbrev": false, "full_module": "Hacl.Bignum.Definitions", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Bignum", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let bn_field_exp_vartime #t km k aM bBits b resM = let open LowStar.BufferOps in let k1 = !*k in push_frame (); let aMc = create k1.len (uint #t #SEC 0) in copy aMc aM; ME.bn_exp_mont_vartime #t km k1.n k1.mu k1.r2 aMc bBits b resM; let h0 = ST.get () in assert (bn_v h0 aM < bn_v_n h0 k); BD.bn_eval_inj (v k1.len) (S.bn_field_exp_vartime (as_pctx h0 k) (as_seq h0 aM) (v bBits) (as_seq h0 b)) (as_seq h0 resM); pop_frame ()
val bn_field_exp_vartime: #t:limb_t -> km:BM.mont t -> bn_field_exp_vartime_st t km.BM.bn.BN.len let bn_field_exp_vartime #t km k aM bBits b resM =
false
null
false
let open LowStar.BufferOps in let k1 = !*k in push_frame (); let aMc = create k1.len (uint #t #SEC 0) in copy aMc aM; ME.bn_exp_mont_vartime #t km k1.n k1.mu k1.r2 aMc bBits b resM; let h0 = ST.get () in assert (bn_v h0 aM < bn_v_n h0 k); BD.bn_eval_inj (v k1.len) (S.bn_field_exp_vartime (as_pctx h0 k) (as_seq h0 aM) (v bBits) (as_seq h0 b)) (as_seq h0 resM); pop_frame ()
{ "checked_file": "Hacl.Bignum.MontArithmetic.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.BufferOps.fst.checked", "LowStar.Buffer.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.MontArithmetic.fst.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.Bignum.Montgomery.fsti.checked", "Hacl.Bignum.MontExponentiation.fst.checked", "Hacl.Bignum.ModInv.fst.checked", "Hacl.Bignum.Lib.fst.checked", "Hacl.Bignum.Exponentiation.fsti.checked", "Hacl.Bignum.Definitions.fst.checked", "Hacl.Bignum.Base.fst.checked", "Hacl.Bignum.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Bignum.MontArithmetic.fst" }
[ "total" ]
[ "Hacl.Bignum.Definitions.limb_t", "Hacl.Bignum.Montgomery.mont", "Hacl.Bignum.MontArithmetic.pbn_mont_ctx", "Hacl.Bignum.Definitions.lbignum", "Hacl.Bignum.__proj__Mkbn__item__len", "Hacl.Bignum.Montgomery.__proj__Mkmont__item__bn", "Lib.IntTypes.size_t", "Hacl.Bignum.Definitions.blocks0", "Lib.IntTypes.size", "Lib.IntTypes.bits", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Spec.Bignum.Definitions.bn_eval_inj", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__len", "Hacl.Bignum.MontArithmetic.lb", "Hacl.Bignum.MontArithmetic.ll", "Hacl.Spec.Bignum.MontArithmetic.bn_field_exp_vartime", "Hacl.Bignum.MontArithmetic.as_pctx", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Hacl.Bignum.Definitions.limb", "Prims._assert", "Prims.b2t", "Prims.op_LessThan", "Hacl.Bignum.Definitions.bn_v", "Hacl.Bignum.MontArithmetic.bn_v_n", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Bignum.MontExponentiation.bn_exp_mont_vartime", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__n", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__mu", "Hacl.Bignum.MontArithmetic.__proj__Mkbn_mont_ctx'__item__r2", "Lib.Buffer.copy", "Lib.Buffer.lbuffer_t", "Lib.Buffer.create", "Lib.IntTypes.uint", "Lib.IntTypes.SEC", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame", "Hacl.Bignum.MontArithmetic.bn_mont_ctx", "LowStar.BufferOps.op_Bang_Star", "LowStar.Buffer.trivial_preorder" ]
[]
module Hacl.Bignum.MontArithmetic open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer open Hacl.Bignum.Definitions module B = LowStar.Buffer module HS = FStar.HyperStack module ST = FStar.HyperStack.ST module S = Hacl.Spec.Bignum.MontArithmetic module BD = Hacl.Spec.Bignum.Definitions module BB = Hacl.Bignum.Base module BL = Hacl.Bignum.Lib module ME = Hacl.Bignum.MontExponentiation module BE = Hacl.Bignum.Exponentiation module BN = Hacl.Bignum module BM = Hacl.Bignum.Montgomery module BI = Hacl.Bignum.ModInv friend Hacl.Spec.Bignum.MontArithmetic #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" let _align_fsti = () let bn_field_get_len #t k = let open LowStar.BufferOps in let k1 = !*k in k1.len let bn_field_check_modulus #t km n = let m = km.BM.mont_check n in BB.unsafe_bool_of_limb m let bn_field_init #t len precomp_r2 r n = let h0 = ST.get () in let r2 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let n1 : buffer (limb t) = B.mmalloc r (uint #t #SEC 0) len in let h1 = ST.get () in B.(modifies_only_not_unused_in loc_none h0 h1); assert (B.length r2 == FStar.UInt32.v len); assert (B.length n1 == FStar.UInt32.v len); let r2 : lbignum t len = r2 in let n1 : lbignum t len = n1 in copy n1 n; let nBits = size (bits t) *! BB.unsafe_size_from_limb (BL.bn_get_top_index len n) in precomp_r2 nBits n r2; let mu = BM.mod_inv_limb n.(0ul) in let res : bn_mont_ctx t = { len = len; n = n1; mu = mu; r2 = r2 } in let h2 = ST.get () in assert (as_ctx h2 res == S.bn_field_init (as_seq h0 n)); assert (S.bn_mont_ctx_inv (as_ctx h2 res)); B.(modifies_only_not_unused_in loc_none h0 h2); B.malloc r res 1ul let bn_field_free #t k = let open LowStar.BufferOps in let k1 = !*k in let n : buffer (limb t) = k1.n in let r2 : buffer (limb t) = k1.r2 in B.free n; B.freeable_disjoint n r2; B.free r2; B.free k let bn_to_field #t km k a aM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.to k1.n k1.mu k1.r2 a aM; let h1 = ST.get () in assert (as_seq h1 aM == S.bn_to_field (as_pctx h0 k) (as_seq h0 a)) let bn_from_field #t km k aM a = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.from k1.n k1.mu aM a; let h1 = ST.get () in assert (as_seq h1 a == S.bn_from_field (as_pctx h0 k) (as_seq h0 aM)) let bn_field_add #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.add_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_add (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_sub #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.bn.BN.sub_mod_n k1.n aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_sub (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_mul #t km k aM bM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.mul k1.n k1.mu aM bM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_mul (as_pctx h0 k) (as_seq h0 aM) (as_seq h0 bM)) let bn_field_sqr #t km k aM cM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in km.BM.sqr k1.n k1.mu aM cM; let h1 = ST.get () in assert (as_seq h1 cM == S.bn_field_sqr (as_pctx h0 k) (as_seq h0 aM)) let bn_field_one #t km k oneM = let open LowStar.BufferOps in let k1 = !*k in let h0 = ST.get () in BM.bn_mont_one km.BM.bn.BN.len km.BM.from k1.n k1.mu k1.r2 oneM; let h1 = ST.get () in assert (as_seq h1 oneM == S.bn_field_one (as_pctx h0 k)) let bn_field_exp_consttime #t km k aM bBits b resM = let open LowStar.BufferOps in let k1 = !*k in push_frame (); let aMc = create k1.len (uint #t #SEC 0) in copy aMc aM; ME.bn_exp_mont_consttime #t km k1.n k1.mu k1.r2 aMc bBits b resM; let h0 = ST.get () in assert (bn_v h0 aM < bn_v_n h0 k); BD.bn_eval_inj (v k1.len) (S.bn_field_exp_consttime (as_pctx h0 k) (as_seq h0 aM) (v bBits) (as_seq h0 b)) (as_seq h0 resM); pop_frame ()
false
false
Hacl.Bignum.MontArithmetic.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 bn_field_exp_vartime: #t:limb_t -> km:BM.mont t -> bn_field_exp_vartime_st t km.BM.bn.BN.len
[]
Hacl.Bignum.MontArithmetic.bn_field_exp_vartime
{ "file_name": "code/bignum/Hacl.Bignum.MontArithmetic.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
km: Hacl.Bignum.Montgomery.mont t -> Hacl.Bignum.MontArithmetic.bn_field_exp_vartime_st t (Mkbn?.len (Mkmont?.bn km))
{ "end_col": 14, "end_line": 169, "start_col": 2, "start_line": 158 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "FStar.Witnessed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Witnessed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let s_predicate (state:Type u#a) = state -> Type0
let s_predicate (state: Type u#a) =
false
null
false
state -> Type0
{ "checked_file": "FStar.Witnessed.Core.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Witnessed.Core.fsti" }
[ "total" ]
[]
[]
module FStar.Witnessed.Core module P = FStar.Preorder
false
true
FStar.Witnessed.Core.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val s_predicate : state: Type -> Type
[]
FStar.Witnessed.Core.s_predicate
{ "file_name": "ulib/experimental/FStar.Witnessed.Core.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
state: Type -> Type
{ "end_col": 49, "end_line": 4, "start_col": 35, "start_line": 4 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Preorder", "short_module": "P" }, { "abbrev": false, "full_module": "FStar.Witnessed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Witnessed", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let stable (state:Type u#a) (rel:P.preorder state) (p:s_predicate state) = forall s0 s1. (p s0 /\ rel s0 s1) ==> p s1
let stable (state: Type u#a) (rel: P.preorder state) (p: s_predicate state) =
false
null
false
forall s0 s1. (p s0 /\ rel s0 s1) ==> p s1
{ "checked_file": "FStar.Witnessed.Core.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Witnessed.Core.fsti" }
[ "total" ]
[ "FStar.Preorder.preorder", "FStar.Witnessed.Core.s_predicate", "Prims.l_Forall", "Prims.l_imp", "Prims.l_and", "Prims.logical" ]
[]
module FStar.Witnessed.Core module P = FStar.Preorder let s_predicate (state:Type u#a) = state -> Type0 let stable (state:Type u#a) (rel:P.preorder state)
false
false
FStar.Witnessed.Core.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val stable : state: Type -> rel: FStar.Preorder.preorder state -> p: FStar.Witnessed.Core.s_predicate state -> Prims.logical
[]
FStar.Witnessed.Core.stable
{ "file_name": "ulib/experimental/FStar.Witnessed.Core.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
state: Type -> rel: FStar.Preorder.preorder state -> p: FStar.Witnessed.Core.s_predicate state -> Prims.logical
{ "end_col": 44, "end_line": 9, "start_col": 2, "start_line": 9 }
FStar.Pervasives.Lemma
val lemma_spec_update_224_256 (b st: _) : Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st)
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_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_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_256 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_256 b st } Spec.Agile.Hash.update SHA2_256 st b; (==) { Spec.SHA2.Lemmas.update_224_256 st b } Spec.Agile.Hash.update SHA2_224 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_224 b st } Hacl.Spec.SHA2.update SHA2_224 b st; }
val lemma_spec_update_224_256 (b st: _) : Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) let lemma_spec_update_224_256 b st : Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) =
false
null
true
calc ( == ) { Hacl.Spec.SHA2.update SHA2_256 b st; ( == ) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_256 b st } Spec.Agile.Hash.update SHA2_256 st b; ( == ) { Spec.SHA2.Lemmas.update_224_256 st b } Spec.Agile.Hash.update SHA2_224 st b; ( == ) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_224 b st } Hacl.Spec.SHA2.update SHA2_224 b st; }
{ "checked_file": "Hacl.SHA2.Scalar32.Lemmas.fst.checked", "dependencies": [ "Spec.SHA2.Lemmas.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.EquivScalar.fsti.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Scalar32.Lemmas.fst" }
[ "lemma" ]
[ "Lib.Sequence.seq", "Lib.IntTypes.uint8", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Spec.Hash.Definitions.block_length", "Spec.Hash.Definitions.SHA2_256", "Spec.Hash.Definitions.SHA2_224", "Spec.Hash.Definitions.word", "Spec.Hash.Definitions.state_word_length", "FStar.Calc.calc_finish", "Spec.Hash.Definitions.words_state", "Hacl.Spec.SHA2.update", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Spec.Agile.Hash.update", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.SHA2.EquivScalar.update_lemma", "Prims.squash", "Spec.SHA2.Lemmas.update_224_256", "Prims.l_True", "Prims.l_or", "FStar.Pervasives.pattern" ]
[]
module Hacl.SHA2.Scalar32.Lemmas open Lib.IntTypes open Spec.Agile.Hash open Hacl.Spec.SHA2.Vec module SpecVec = Hacl.Spec.SHA2.Vec #push-options "--fuel 0 --ifuel 0 --z3rlimit 50" let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) = let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[0] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[0] <: lseq (word a) 8 in let aux (i:nat{i < 8}) : Lemma (acc1.[i] == acc2.[i]) = assert (index (vec_v acc1.[i]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[i]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[i]) 0 == index (vec_v acc2.[i]) 0); eq_intro (vec_v acc1.[i]) (vec_v acc2.[i]); vecv_extensionality acc1.[i] acc2.[i] in Classical.forall_intro aux; eq_intro acc1 acc2 let lemma_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st)
false
false
Hacl.SHA2.Scalar32.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_spec_update_224_256 (b st: _) : Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st)
[]
Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_224_256
{ "file_name": "code/sha2-mb/Hacl.SHA2.Scalar32.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: s: Lib.Sequence.seq Lib.IntTypes.uint8 { FStar.Seq.Base.length s == Spec.Hash.Definitions.block_length Spec.Hash.Definitions.SHA2_256 /\ FStar.Seq.Base.length s == Spec.Hash.Definitions.block_length Spec.Hash.Definitions.SHA2_224 } -> st: s: Lib.Sequence.seq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_224) { FStar.Seq.Base.length s == Spec.Hash.Definitions.state_word_length Spec.Hash.Definitions.SHA2_224 /\ FStar.Seq.Base.length s == Spec.Hash.Definitions.state_word_length Spec.Hash.Definitions.SHA2_256 } -> FStar.Pervasives.Lemma (ensures Hacl.Spec.SHA2.update Spec.Hash.Definitions.SHA2_256 b st == Hacl.Spec.SHA2.update Spec.Hash.Definitions.SHA2_224 b st)
{ "end_col": 3, "end_line": 48, "start_col": 2, "start_line": 40 }
FStar.Pervasives.Lemma
val lemma_spec_update_384_512 (b st: _) : Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st)
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_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_spec_update_384_512 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_512 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_512 b st } Spec.Agile.Hash.update SHA2_512 st b; (==) { Spec.SHA2.Lemmas.update_384_512 st b } Spec.Agile.Hash.update SHA2_384 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_384 b st } Hacl.Spec.SHA2.update SHA2_384 b st; }
val lemma_spec_update_384_512 (b st: _) : Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st) let lemma_spec_update_384_512 b st : Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st) =
false
null
true
calc ( == ) { Hacl.Spec.SHA2.update SHA2_512 b st; ( == ) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_512 b st } Spec.Agile.Hash.update SHA2_512 st b; ( == ) { Spec.SHA2.Lemmas.update_384_512 st b } Spec.Agile.Hash.update SHA2_384 st b; ( == ) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_384 b st } Hacl.Spec.SHA2.update SHA2_384 b st; }
{ "checked_file": "Hacl.SHA2.Scalar32.Lemmas.fst.checked", "dependencies": [ "Spec.SHA2.Lemmas.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.EquivScalar.fsti.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Scalar32.Lemmas.fst" }
[ "lemma" ]
[ "Lib.Sequence.seq", "Lib.IntTypes.uint8", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Spec.Hash.Definitions.block_length", "Spec.Hash.Definitions.SHA2_512", "Spec.Hash.Definitions.SHA2_384", "Spec.Hash.Definitions.word", "Spec.Hash.Definitions.state_word_length", "FStar.Calc.calc_finish", "Spec.Hash.Definitions.words_state", "Hacl.Spec.SHA2.update", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "Prims.unit", "FStar.Calc.calc_step", "Spec.Agile.Hash.update", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Hacl.Spec.SHA2.EquivScalar.update_lemma", "Prims.squash", "Spec.SHA2.Lemmas.update_384_512", "Prims.l_True", "Prims.l_or", "FStar.Pervasives.pattern" ]
[]
module Hacl.SHA2.Scalar32.Lemmas open Lib.IntTypes open Spec.Agile.Hash open Hacl.Spec.SHA2.Vec module SpecVec = Hacl.Spec.SHA2.Vec #push-options "--fuel 0 --ifuel 0 --z3rlimit 50" let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) = let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[0] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[0] <: lseq (word a) 8 in let aux (i:nat{i < 8}) : Lemma (acc1.[i] == acc2.[i]) = assert (index (vec_v acc1.[i]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[i]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[i]) 0 == index (vec_v acc2.[i]) 0); eq_intro (vec_v acc1.[i]) (vec_v acc2.[i]); vecv_extensionality acc1.[i] acc2.[i] in Classical.forall_intro aux; eq_intro acc1 acc2 let lemma_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_256 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_256 b st } Spec.Agile.Hash.update SHA2_256 st b; (==) { Spec.SHA2.Lemmas.update_224_256 st b } Spec.Agile.Hash.update SHA2_224 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_224 b st } Hacl.Spec.SHA2.update SHA2_224 b st; } let lemma_spec_update_vec_224_256 b0 st0 : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_256 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_256 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_256 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_256 b0.(|0|) st0_m32; (==) { lemma_spec_update_224_256 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_224 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_224 #M32 b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update #SHA2_224 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update #SHA2_256 b0 st0) (SpecVec.update #SHA2_224 #M32 b0 st0) let lemma_spec_update_nblocks_vec_224_256 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0)) = let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let st1 = SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let b0_m32' = Seq.slice b0.(|0|) 0 (Seq.length b0.(|0|) - Seq.length b0.(|0|) % block_length SHA2_256) in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_256 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_256 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_256 (v len) b0.(|0|) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) st0_m32; (==) { FStar.Classical.forall_intro_2 lemma_spec_update_224_256; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) (Hacl.Spec.SHA2.update SHA2_224) st0_m32 } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) st0_m32; (==) { } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_224) (block_length SHA2_224) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) (st0_m32 <: words_state SHA2_224); (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_224 (v len) b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_224 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_224 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update_nblocks #SHA2_224 (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0) let lemma_spec_update_last_vec_224_256 totlen (len:size_t{v len <= block_length SHA2_256}) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0)) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let hacl_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) [ SMTPat (Hacl.Spec.SHA2.update SHA2_256 b st) ] = lemma_spec_update_224_256 b st in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_last #SHA2_256 totlen (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_256 #M32 totlen (v len) b0 st0 0 } Hacl.Spec.SHA2.update_last SHA2_256 totlen (v len) b0.(|0|) st0_m32; (==) { } Hacl.Spec.SHA2.update_last SHA2_224 totlen (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_224 #M32 totlen (v len) b0 st0 0 } (state_spec_v (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0) (SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0) let lemma_spec_update_384_512 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st)
false
false
Hacl.SHA2.Scalar32.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_spec_update_384_512 (b st: _) : Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st)
[]
Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_384_512
{ "file_name": "code/sha2-mb/Hacl.SHA2.Scalar32.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: s: Lib.Sequence.seq Lib.IntTypes.uint8 { FStar.Seq.Base.length s == Spec.Hash.Definitions.block_length Spec.Hash.Definitions.SHA2_512 /\ FStar.Seq.Base.length s == Spec.Hash.Definitions.block_length Spec.Hash.Definitions.SHA2_384 } -> st: s: Lib.Sequence.seq (Spec.Hash.Definitions.word Spec.Hash.Definitions.SHA2_384) { FStar.Seq.Base.length s == Spec.Hash.Definitions.state_word_length Spec.Hash.Definitions.SHA2_384 /\ FStar.Seq.Base.length s == Spec.Hash.Definitions.state_word_length Spec.Hash.Definitions.SHA2_512 } -> FStar.Pervasives.Lemma (ensures Hacl.Spec.SHA2.update Spec.Hash.Definitions.SHA2_512 b st == Hacl.Spec.SHA2.update Spec.Hash.Definitions.SHA2_384 b st)
{ "end_col": 3, "end_line": 158, "start_col": 2, "start_line": 150 }
FStar.Pervasives.Lemma
val lemma_spec_update_vec_384_512 (b0 st0: _) : Lemma (ensures SpecVec.update #SHA2_384 #M32 b0 st0 == SpecVec.update #SHA2_512 #M32 b0 st0)
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_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_spec_update_vec_384_512 b0 st0 : Lemma (ensures SpecVec.update #SHA2_384 #M32 b0 st0 == SpecVec.update #SHA2_512 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_512 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_512 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_512 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_512 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_512 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_512 b0.(|0|) st0_m32; (==) { lemma_spec_update_384_512 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_384 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_384 #M32 b0 st0 0 } (state_spec_v #SHA2_384 #M32 (SpecVec.update #SHA2_384 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_512 (SpecVec.update #SHA2_512 b0 st0) (SpecVec.update #SHA2_384 #M32 b0 st0)
val lemma_spec_update_vec_384_512 (b0 st0: _) : Lemma (ensures SpecVec.update #SHA2_384 #M32 b0 st0 == SpecVec.update #SHA2_512 #M32 b0 st0) let lemma_spec_update_vec_384_512 b0 st0 : Lemma (ensures SpecVec.update #SHA2_384 #M32 b0 st0 == SpecVec.update #SHA2_512 #M32 b0 st0) =
false
null
true
let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_512 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[ 0 ] <: words_state SHA2_512 in let st1_m32 = (state_spec_v st1).[ 0 ] <: words_state SHA2_512 in calc ( == ) { st1_m32; ( == ) { () } (state_spec_v (SpecVec.update #SHA2_512 b0 st0)).[ 0 ]; ( == ) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_512 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_512 b0.(| 0 |) st0_m32; ( == ) { lemma_spec_update_384_512 b0.(| 0 |) st0_m32 } Hacl.Spec.SHA2.update SHA2_384 b0.(| 0 |) st0_m32; ( == ) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_384 #M32 b0 st0 0 } (state_spec_v #SHA2_384 #M32 (SpecVec.update #SHA2_384 b0 st0)).[ 0 ]; }; state_spec_v_extensionality SHA2_512 (SpecVec.update #SHA2_512 b0 st0) (SpecVec.update #SHA2_384 #M32 b0 st0)
{ "checked_file": "Hacl.SHA2.Scalar32.Lemmas.fst.checked", "dependencies": [ "Spec.SHA2.Lemmas.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.EquivScalar.fsti.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Scalar32.Lemmas.fst" }
[ "lemma" ]
[ "Hacl.Spec.SHA2.Vec.multiblock_spec", "Spec.Hash.Definitions.SHA2_384", "Hacl.Spec.SHA2.Vec.M32", "Lib.Sequence.seq", "Hacl.Spec.SHA2.Vec.element_t", "Spec.Hash.Definitions.SHA2_512", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Hacl.SHA2.Scalar32.Lemmas.state_spec_v_extensionality", "Hacl.Spec.SHA2.Vec.update", "Prims.unit", "FStar.Calc.calc_finish", "Spec.Hash.Definitions.words_state", "Lib.Sequence.op_String_Access", "Hacl.Spec.SHA2.Vec.words_state'", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.state_spec_v", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Hacl.Spec.SHA2.update", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.block_length", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Hacl.Spec.SHA2.Equiv.update_lemma_l", "Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_384_512", "Hacl.Spec.SHA2.Vec.state_spec", "Prims.l_True", "Prims.l_or", "FStar.Pervasives.pattern" ]
[]
module Hacl.SHA2.Scalar32.Lemmas open Lib.IntTypes open Spec.Agile.Hash open Hacl.Spec.SHA2.Vec module SpecVec = Hacl.Spec.SHA2.Vec #push-options "--fuel 0 --ifuel 0 --z3rlimit 50" let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) = let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[0] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[0] <: lseq (word a) 8 in let aux (i:nat{i < 8}) : Lemma (acc1.[i] == acc2.[i]) = assert (index (vec_v acc1.[i]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[i]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[i]) 0 == index (vec_v acc2.[i]) 0); eq_intro (vec_v acc1.[i]) (vec_v acc2.[i]); vecv_extensionality acc1.[i] acc2.[i] in Classical.forall_intro aux; eq_intro acc1 acc2 let lemma_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_256 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_256 b st } Spec.Agile.Hash.update SHA2_256 st b; (==) { Spec.SHA2.Lemmas.update_224_256 st b } Spec.Agile.Hash.update SHA2_224 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_224 b st } Hacl.Spec.SHA2.update SHA2_224 b st; } let lemma_spec_update_vec_224_256 b0 st0 : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_256 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_256 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_256 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_256 b0.(|0|) st0_m32; (==) { lemma_spec_update_224_256 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_224 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_224 #M32 b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update #SHA2_224 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update #SHA2_256 b0 st0) (SpecVec.update #SHA2_224 #M32 b0 st0) let lemma_spec_update_nblocks_vec_224_256 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0)) = let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let st1 = SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let b0_m32' = Seq.slice b0.(|0|) 0 (Seq.length b0.(|0|) - Seq.length b0.(|0|) % block_length SHA2_256) in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_256 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_256 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_256 (v len) b0.(|0|) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) st0_m32; (==) { FStar.Classical.forall_intro_2 lemma_spec_update_224_256; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) (Hacl.Spec.SHA2.update SHA2_224) st0_m32 } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) st0_m32; (==) { } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_224) (block_length SHA2_224) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) (st0_m32 <: words_state SHA2_224); (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_224 (v len) b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_224 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_224 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update_nblocks #SHA2_224 (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0) let lemma_spec_update_last_vec_224_256 totlen (len:size_t{v len <= block_length SHA2_256}) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0)) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let hacl_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) [ SMTPat (Hacl.Spec.SHA2.update SHA2_256 b st) ] = lemma_spec_update_224_256 b st in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_last #SHA2_256 totlen (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_256 #M32 totlen (v len) b0 st0 0 } Hacl.Spec.SHA2.update_last SHA2_256 totlen (v len) b0.(|0|) st0_m32; (==) { } Hacl.Spec.SHA2.update_last SHA2_224 totlen (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_224 #M32 totlen (v len) b0 st0 0 } (state_spec_v (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0) (SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0) let lemma_spec_update_384_512 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_512 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_512 b st } Spec.Agile.Hash.update SHA2_512 st b; (==) { Spec.SHA2.Lemmas.update_384_512 st b } Spec.Agile.Hash.update SHA2_384 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_384 b st } Hacl.Spec.SHA2.update SHA2_384 b st; } let lemma_spec_update_vec_384_512 b0 st0 : Lemma (ensures SpecVec.update #SHA2_384 #M32 b0 st0 == SpecVec.update #SHA2_512 #M32 b0 st0)
false
false
Hacl.SHA2.Scalar32.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_spec_update_vec_384_512 (b0 st0: _) : Lemma (ensures SpecVec.update #SHA2_384 #M32 b0 st0 == SpecVec.update #SHA2_512 #M32 b0 st0)
[]
Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_vec_384_512
{ "file_name": "code/sha2-mb/Hacl.SHA2.Scalar32.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b0: Hacl.Spec.SHA2.Vec.multiblock_spec Spec.Hash.Definitions.SHA2_384 Hacl.Spec.SHA2.Vec.M32 -> st0: s: Lib.Sequence.seq (Hacl.Spec.SHA2.Vec.element_t Spec.Hash.Definitions.SHA2_512 Hacl.Spec.SHA2.Vec.M32) {FStar.Seq.Base.length s == 8 /\ FStar.Seq.Base.length s == 8} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.SHA2.Vec.update b0 st0 == Hacl.Spec.SHA2.Vec.update b0 st0)
{ "end_col": 44, "end_line": 182, "start_col": 2, "start_line": 164 }
FStar.Pervasives.Lemma
val lemma_spec_update_vec_224_256 (b0 st0: _) : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0)
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_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_spec_update_vec_224_256 b0 st0 : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_256 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_256 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_256 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_256 b0.(|0|) st0_m32; (==) { lemma_spec_update_224_256 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_224 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_224 #M32 b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update #SHA2_224 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update #SHA2_256 b0 st0) (SpecVec.update #SHA2_224 #M32 b0 st0)
val lemma_spec_update_vec_224_256 (b0 st0: _) : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0) let lemma_spec_update_vec_224_256 b0 st0 : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0) =
false
null
true
let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_256 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[ 0 ] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[ 0 ] <: words_state SHA2_256 in calc ( == ) { st1_m32; ( == ) { () } (state_spec_v (SpecVec.update #SHA2_256 b0 st0)).[ 0 ]; ( == ) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_256 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_256 b0.(| 0 |) st0_m32; ( == ) { lemma_spec_update_224_256 b0.(| 0 |) st0_m32 } Hacl.Spec.SHA2.update SHA2_224 b0.(| 0 |) st0_m32; ( == ) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_224 #M32 b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update #SHA2_224 b0 st0)).[ 0 ]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update #SHA2_256 b0 st0) (SpecVec.update #SHA2_224 #M32 b0 st0)
{ "checked_file": "Hacl.SHA2.Scalar32.Lemmas.fst.checked", "dependencies": [ "Spec.SHA2.Lemmas.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.EquivScalar.fsti.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Scalar32.Lemmas.fst" }
[ "lemma" ]
[ "Hacl.Spec.SHA2.Vec.multiblock_spec", "Spec.Hash.Definitions.SHA2_224", "Hacl.Spec.SHA2.Vec.M32", "Lib.Sequence.seq", "Hacl.Spec.SHA2.Vec.element_t", "Spec.Hash.Definitions.SHA2_256", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Hacl.SHA2.Scalar32.Lemmas.state_spec_v_extensionality", "Hacl.Spec.SHA2.Vec.update", "Prims.unit", "FStar.Calc.calc_finish", "Spec.Hash.Definitions.words_state", "Lib.Sequence.op_String_Access", "Hacl.Spec.SHA2.Vec.words_state'", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.state_spec_v", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Hacl.Spec.SHA2.update", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "Spec.Hash.Definitions.block_length", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Hacl.Spec.SHA2.Equiv.update_lemma_l", "Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_224_256", "Hacl.Spec.SHA2.Vec.state_spec", "Prims.l_True", "Prims.l_or", "FStar.Pervasives.pattern" ]
[]
module Hacl.SHA2.Scalar32.Lemmas open Lib.IntTypes open Spec.Agile.Hash open Hacl.Spec.SHA2.Vec module SpecVec = Hacl.Spec.SHA2.Vec #push-options "--fuel 0 --ifuel 0 --z3rlimit 50" let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) = let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[0] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[0] <: lseq (word a) 8 in let aux (i:nat{i < 8}) : Lemma (acc1.[i] == acc2.[i]) = assert (index (vec_v acc1.[i]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[i]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[i]) 0 == index (vec_v acc2.[i]) 0); eq_intro (vec_v acc1.[i]) (vec_v acc2.[i]); vecv_extensionality acc1.[i] acc2.[i] in Classical.forall_intro aux; eq_intro acc1 acc2 let lemma_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_256 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_256 b st } Spec.Agile.Hash.update SHA2_256 st b; (==) { Spec.SHA2.Lemmas.update_224_256 st b } Spec.Agile.Hash.update SHA2_224 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_224 b st } Hacl.Spec.SHA2.update SHA2_224 b st; } let lemma_spec_update_vec_224_256 b0 st0 : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0)
false
false
Hacl.SHA2.Scalar32.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_spec_update_vec_224_256 (b0 st0: _) : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0)
[]
Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_vec_224_256
{ "file_name": "code/sha2-mb/Hacl.SHA2.Scalar32.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b0: Hacl.Spec.SHA2.Vec.multiblock_spec Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M32 -> st0: s: Lib.Sequence.seq (Hacl.Spec.SHA2.Vec.element_t Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M32) {FStar.Seq.Base.length s == 8 /\ FStar.Seq.Base.length s == 8} -> FStar.Pervasives.Lemma (ensures Hacl.Spec.SHA2.Vec.update b0 st0 == Hacl.Spec.SHA2.Vec.update b0 st0)
{ "end_col": 44, "end_line": 72, "start_col": 2, "start_line": 54 }
FStar.Pervasives.Lemma
val state_spec_v_extensionality (a: hash_alg{is_sha2 a}) (acc1 acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2)
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) = let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[0] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[0] <: lseq (word a) 8 in let aux (i:nat{i < 8}) : Lemma (acc1.[i] == acc2.[i]) = assert (index (vec_v acc1.[i]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[i]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[i]) 0 == index (vec_v acc2.[i]) 0); eq_intro (vec_v acc1.[i]) (vec_v acc2.[i]); vecv_extensionality acc1.[i] acc2.[i] in Classical.forall_intro aux; eq_intro acc1 acc2
val state_spec_v_extensionality (a: hash_alg{is_sha2 a}) (acc1 acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) let state_spec_v_extensionality (a: hash_alg{is_sha2 a}) (acc1 acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) =
false
null
true
let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[ 0 ] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[ 0 ] <: lseq (word a) 8 in let aux (i: nat{i < 8}) : Lemma (acc1.[ i ] == acc2.[ i ]) = assert (index (vec_v acc1.[ i ]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[ i ]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[ i ]) 0 == index (vec_v acc2.[ i ]) 0); eq_intro (vec_v acc1.[ i ]) (vec_v acc2.[ i ]); vecv_extensionality acc1.[ i ] acc2.[ i ] in Classical.forall_intro aux; eq_intro acc1 acc2
{ "checked_file": "Hacl.SHA2.Scalar32.Lemmas.fst.checked", "dependencies": [ "Spec.SHA2.Lemmas.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.EquivScalar.fsti.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Scalar32.Lemmas.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.hash_alg", "Prims.b2t", "Spec.Hash.Definitions.is_sha2", "Hacl.Spec.SHA2.Vec.state_spec", "Hacl.Spec.SHA2.Vec.M32", "Lib.Sequence.eq_intro", "Hacl.Spec.SHA2.Vec.element_t", "Prims.unit", "FStar.Classical.forall_intro", "Prims.nat", "Prims.op_LessThan", "Prims.eq2", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.op_String_Access", "Prims.l_True", "Prims.squash", "Lib.Sequence.index", "Prims.Nil", "FStar.Pervasives.pattern", "Lib.IntVector.vecv_extensionality", "Spec.Hash.Definitions.word_t", "Hacl.Spec.SHA2.Vec.lanes", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntVector.vec_v", "Prims._assert", "Hacl.Spec.SHA2.Vec.word", "Lib.Sequence.lseq", "Hacl.Spec.SHA2.Vec.words_state'", "Hacl.Spec.SHA2.Vec.state_spec_v", "FStar.Pervasives.allow_inversion" ]
[]
module Hacl.SHA2.Scalar32.Lemmas open Lib.IntTypes open Spec.Agile.Hash open Hacl.Spec.SHA2.Vec module SpecVec = Hacl.Spec.SHA2.Vec #push-options "--fuel 0 --ifuel 0 --z3rlimit 50" let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) =
false
false
Hacl.SHA2.Scalar32.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val state_spec_v_extensionality (a: hash_alg{is_sha2 a}) (acc1 acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2)
[]
Hacl.SHA2.Scalar32.Lemmas.state_spec_v_extensionality
{ "file_name": "code/sha2-mb/Hacl.SHA2.Scalar32.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Hash.Definitions.hash_alg{Spec.Hash.Definitions.is_sha2 a} -> acc1: Hacl.Spec.SHA2.Vec.state_spec a Hacl.Spec.SHA2.Vec.M32 -> acc2: Hacl.Spec.SHA2.Vec.state_spec a Hacl.Spec.SHA2.Vec.M32 -> FStar.Pervasives.Lemma (requires Lib.Sequence.index (Hacl.Spec.SHA2.Vec.state_spec_v acc1) 0 == Lib.Sequence.index (Hacl.Spec.SHA2.Vec.state_spec_v acc2) 0) (ensures acc1 == acc2)
{ "end_col": 20, "end_line": 34, "start_col": 2, "start_line": 19 }
FStar.Pervasives.Lemma
val lemma_spec_update_nblocks_vec_384_512 (len: size_t) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_512 #M32 (v len) b0 st0))
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_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_spec_update_nblocks_vec_384_512 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_512 #M32 (v len) b0 st0)) = let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; let st1 = SpecVec.update_nblocks #SHA2_512 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_512 in let b0_m32' = Seq.slice b0.(|0|) 0 (Seq.length b0.(|0|) - Seq.length b0.(|0|) % block_length SHA2_512) in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_512 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_nblocks #SHA2_512 (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_512 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_512 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_512 (v len) b0.(|0|) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_512) b0_m32' (Hacl.Spec.SHA2.update SHA2_512) st0_m32; (==) { FStar.Classical.forall_intro_2 lemma_spec_update_384_512; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_512) (block_length SHA2_512) b0_m32' (Hacl.Spec.SHA2.update SHA2_512) (Hacl.Spec.SHA2.update SHA2_384) st0_m32 } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_512) (block_length SHA2_512) b0_m32' (Hacl.Spec.SHA2.update SHA2_384) st0_m32; (==) { } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_384) (block_length SHA2_384) b0_m32' (Hacl.Spec.SHA2.update SHA2_384) (st0_m32 <: words_state SHA2_384); (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_384 (v len) b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_384 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_384 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_384 #M32 (SpecVec.update_nblocks #SHA2_384 (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_512 (SpecVec.update_nblocks #SHA2_512 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0)
val lemma_spec_update_nblocks_vec_384_512 (len: size_t) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_512 #M32 (v len) b0 st0)) let lemma_spec_update_nblocks_vec_384_512 (len: size_t) b0 st0 : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_512 #M32 (v len) b0 st0)) =
false
null
true
let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; let st1 = SpecVec.update_nblocks #SHA2_512 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[ 0 ] <: words_state SHA2_512 in let b0_m32' = Seq.slice b0.(| 0 |) 0 (Seq.length b0.(| 0 |) - Seq.length b0.(| 0 |) % block_length SHA2_512) in let st1_m32 = (state_spec_v st1).[ 0 ] <: words_state SHA2_512 in calc ( == ) { st1_m32; ( == ) { () } (state_spec_v (SpecVec.update_nblocks #SHA2_512 (v len) b0 st0)).[ 0 ]; ( == ) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_512 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_512 (v len) b0.(| 0 |) st0_m32; ( == ) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_512 (v len) b0.(| 0 |) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_512) b0_m32' (Hacl.Spec.SHA2.update SHA2_512) st0_m32; ( == ) { (FStar.Classical.forall_intro_2 lemma_spec_update_384_512; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_512) (block_length SHA2_512) b0_m32' (Hacl.Spec.SHA2.update SHA2_512) (Hacl.Spec.SHA2.update SHA2_384) st0_m32) } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_512) (block_length SHA2_512) b0_m32' (Hacl.Spec.SHA2.update SHA2_384) st0_m32; ( == ) { () } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_384) (block_length SHA2_384) b0_m32' (Hacl.Spec.SHA2.update SHA2_384) (st0_m32 <: words_state SHA2_384); ( == ) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_384 (v len) b0.(| 0 |) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_384 (v len) b0.(| 0 |) st0_m32; ( == ) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_384 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_384 #M32 (SpecVec.update_nblocks #SHA2_384 (v len) b0 st0)).[ 0 ]; }; state_spec_v_extensionality SHA2_512 (SpecVec.update_nblocks #SHA2_512 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0)
{ "checked_file": "Hacl.SHA2.Scalar32.Lemmas.fst.checked", "dependencies": [ "Spec.SHA2.Lemmas.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.EquivScalar.fsti.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Scalar32.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.size_t", "Hacl.Spec.SHA2.Vec.multiseq", "Hacl.Spec.SHA2.Vec.lanes", "Spec.Hash.Definitions.SHA2_384", "Hacl.Spec.SHA2.Vec.M32", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Sequence.seq", "Hacl.Spec.SHA2.Vec.element_t", "Spec.Hash.Definitions.SHA2_512", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Hacl.SHA2.Scalar32.Lemmas.state_spec_v_extensionality", "Hacl.Spec.SHA2.Vec.update_nblocks", "Prims.unit", "FStar.Calc.calc_finish", "Spec.Hash.Definitions.words_state", "Lib.Sequence.op_String_Access", "Hacl.Spec.SHA2.Vec.words_state'", "Hacl.Spec.SHA2.Vec.state_spec_v", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Hacl.Spec.SHA2.update_nblocks", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "Lib.Sequence.repeat_blocks_multi", "Spec.Hash.Definitions.block_length", "Hacl.Spec.SHA2.update", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l", "Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi", "Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality", "FStar.Classical.forall_intro_2", "Spec.Hash.Definitions.word", "Spec.Hash.Definitions.state_word_length", "Prims.l_or", "Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_384_512", "FStar.Seq.Base.seq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.Seq.Base.slice", "Prims.op_Subtraction", "Prims.op_Modulus", "Hacl.Spec.SHA2.Vec.state_spec", "Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t", "Prims.l_True", "FStar.Pervasives.pattern" ]
[]
module Hacl.SHA2.Scalar32.Lemmas open Lib.IntTypes open Spec.Agile.Hash open Hacl.Spec.SHA2.Vec module SpecVec = Hacl.Spec.SHA2.Vec #push-options "--fuel 0 --ifuel 0 --z3rlimit 50" let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) = let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[0] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[0] <: lseq (word a) 8 in let aux (i:nat{i < 8}) : Lemma (acc1.[i] == acc2.[i]) = assert (index (vec_v acc1.[i]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[i]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[i]) 0 == index (vec_v acc2.[i]) 0); eq_intro (vec_v acc1.[i]) (vec_v acc2.[i]); vecv_extensionality acc1.[i] acc2.[i] in Classical.forall_intro aux; eq_intro acc1 acc2 let lemma_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_256 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_256 b st } Spec.Agile.Hash.update SHA2_256 st b; (==) { Spec.SHA2.Lemmas.update_224_256 st b } Spec.Agile.Hash.update SHA2_224 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_224 b st } Hacl.Spec.SHA2.update SHA2_224 b st; } let lemma_spec_update_vec_224_256 b0 st0 : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_256 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_256 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_256 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_256 b0.(|0|) st0_m32; (==) { lemma_spec_update_224_256 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_224 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_224 #M32 b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update #SHA2_224 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update #SHA2_256 b0 st0) (SpecVec.update #SHA2_224 #M32 b0 st0) let lemma_spec_update_nblocks_vec_224_256 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0)) = let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let st1 = SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let b0_m32' = Seq.slice b0.(|0|) 0 (Seq.length b0.(|0|) - Seq.length b0.(|0|) % block_length SHA2_256) in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_256 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_256 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_256 (v len) b0.(|0|) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) st0_m32; (==) { FStar.Classical.forall_intro_2 lemma_spec_update_224_256; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) (Hacl.Spec.SHA2.update SHA2_224) st0_m32 } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) st0_m32; (==) { } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_224) (block_length SHA2_224) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) (st0_m32 <: words_state SHA2_224); (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_224 (v len) b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_224 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_224 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update_nblocks #SHA2_224 (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0) let lemma_spec_update_last_vec_224_256 totlen (len:size_t{v len <= block_length SHA2_256}) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0)) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let hacl_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) [ SMTPat (Hacl.Spec.SHA2.update SHA2_256 b st) ] = lemma_spec_update_224_256 b st in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_last #SHA2_256 totlen (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_256 #M32 totlen (v len) b0 st0 0 } Hacl.Spec.SHA2.update_last SHA2_256 totlen (v len) b0.(|0|) st0_m32; (==) { } Hacl.Spec.SHA2.update_last SHA2_224 totlen (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_224 #M32 totlen (v len) b0 st0 0 } (state_spec_v (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0) (SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0) let lemma_spec_update_384_512 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_512 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_512 b st } Spec.Agile.Hash.update SHA2_512 st b; (==) { Spec.SHA2.Lemmas.update_384_512 st b } Spec.Agile.Hash.update SHA2_384 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_384 b st } Hacl.Spec.SHA2.update SHA2_384 b st; } let lemma_spec_update_vec_384_512 b0 st0 : Lemma (ensures SpecVec.update #SHA2_384 #M32 b0 st0 == SpecVec.update #SHA2_512 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_512 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_512 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_512 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_512 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_512 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_512 b0.(|0|) st0_m32; (==) { lemma_spec_update_384_512 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_384 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_384 #M32 b0 st0 0 } (state_spec_v #SHA2_384 #M32 (SpecVec.update #SHA2_384 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_512 (SpecVec.update #SHA2_512 b0 st0) (SpecVec.update #SHA2_384 #M32 b0 st0) let lemma_spec_update_nblocks_vec_384_512 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0 ==
false
false
Hacl.SHA2.Scalar32.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_spec_update_nblocks_vec_384_512 (len: size_t) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_512 #M32 (v len) b0 st0))
[]
Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_nblocks_vec_384_512
{ "file_name": "code/sha2-mb/Hacl.SHA2.Scalar32.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t -> b0: Hacl.Spec.SHA2.Vec.multiseq (Hacl.Spec.SHA2.Vec.lanes Spec.Hash.Definitions.SHA2_384 Hacl.Spec.SHA2.Vec.M32) (Lib.IntTypes.v len) -> st0: s: Lib.Sequence.seq (Hacl.Spec.SHA2.Vec.element_t Spec.Hash.Definitions.SHA2_512 Hacl.Spec.SHA2.Vec.M32) {FStar.Seq.Base.length s == 8 /\ FStar.Seq.Base.length s == 8} -> FStar.Pervasives.Lemma (ensures ([@@ FStar.Pervasives.inline_let ]let _ = Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t Spec.Hash.Definitions.SHA2_512 len in Hacl.Spec.SHA2.Vec.update_nblocks (Lib.IntTypes.v len) b0 st0 == Hacl.Spec.SHA2.Vec.update_nblocks (Lib.IntTypes.v len) b0 st0))
{ "end_col": 60, "end_line": 221, "start_col": 4, "start_line": 188 }
FStar.Pervasives.Lemma
val lemma_spec_update_last_vec_384_512 (totlen: _) (len: size_t{v len <= block_length SHA2_512}) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_512 #M32 totlen (v len) b0 st0))
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_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_spec_update_last_vec_384_512 totlen (len:size_t{v len <= block_length SHA2_512}) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_512 #M32 totlen (v len) b0 st0)) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update_last #SHA2_512 #M32 totlen (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_512 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_512 in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; let hacl_spec_update_384_512 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st) [ SMTPat (Hacl.Spec.SHA2.update SHA2_512 b st) ] = lemma_spec_update_384_512 b st in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_last #SHA2_512 totlen (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_512 #M32 totlen (v len) b0 st0 0 } Hacl.Spec.SHA2.update_last SHA2_512 totlen (v len) b0.(|0|) st0_m32; (==) { } Hacl.Spec.SHA2.update_last SHA2_384 totlen (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_384 #M32 totlen (v len) b0 st0 0 } (state_spec_v (SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_512 (SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0) (SpecVec.update_last #SHA2_512 #M32 totlen (v len) b0 st0)
val lemma_spec_update_last_vec_384_512 (totlen: _) (len: size_t{v len <= block_length SHA2_512}) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_512 #M32 totlen (v len) b0 st0)) let lemma_spec_update_last_vec_384_512 totlen (len: size_t{v len <= block_length SHA2_512}) b0 st0 : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_512 #M32 totlen (v len) b0 st0)) =
false
null
true
let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update_last #SHA2_512 #M32 totlen (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[ 0 ] <: words_state SHA2_512 in let st1_m32 = (state_spec_v st1).[ 0 ] <: words_state SHA2_512 in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; let hacl_spec_update_384_512 b st : Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st) [SMTPat (Hacl.Spec.SHA2.update SHA2_512 b st)] = lemma_spec_update_384_512 b st in calc ( == ) { st1_m32; ( == ) { () } (state_spec_v (SpecVec.update_last #SHA2_512 totlen (v len) b0 st0)).[ 0 ]; ( == ) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_512 #M32 totlen (v len) b0 st0 0 } Hacl.Spec.SHA2.update_last SHA2_512 totlen (v len) b0.(| 0 |) st0_m32; ( == ) { () } Hacl.Spec.SHA2.update_last SHA2_384 totlen (v len) b0.(| 0 |) st0_m32; ( == ) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_384 #M32 totlen (v len) b0 st0 0 } (state_spec_v (SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0)).[ 0 ]; }; state_spec_v_extensionality SHA2_512 (SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0) (SpecVec.update_last #SHA2_512 #M32 totlen (v len) b0 st0)
{ "checked_file": "Hacl.SHA2.Scalar32.Lemmas.fst.checked", "dependencies": [ "Spec.SHA2.Lemmas.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.EquivScalar.fsti.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Scalar32.Lemmas.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.len_t", "Spec.Hash.Definitions.SHA2_384", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Spec.Hash.Definitions.SHA2_512", "Hacl.Spec.SHA2.Vec.multiseq", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.M32", "Lib.Sequence.seq", "Hacl.Spec.SHA2.Vec.element_t", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Hacl.SHA2.Scalar32.Lemmas.state_spec_v_extensionality", "Hacl.Spec.SHA2.Vec.update_last", "Prims.unit", "FStar.Calc.calc_finish", "Spec.Hash.Definitions.words_state", "Lib.Sequence.op_String_Access", "Hacl.Spec.SHA2.Vec.words_state'", "Hacl.Spec.SHA2.Vec.state_spec_v", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Hacl.Spec.SHA2.update_last", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Hacl.Spec.SHA2.Equiv.update_last_lemma_l", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Hash.Definitions.word", "Spec.Hash.Definitions.state_word_length", "Prims.l_True", "Prims.l_or", "Hacl.Spec.SHA2.update", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_384_512", "Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t", "Hacl.Spec.SHA2.Vec.state_spec" ]
[]
module Hacl.SHA2.Scalar32.Lemmas open Lib.IntTypes open Spec.Agile.Hash open Hacl.Spec.SHA2.Vec module SpecVec = Hacl.Spec.SHA2.Vec #push-options "--fuel 0 --ifuel 0 --z3rlimit 50" let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) = let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[0] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[0] <: lseq (word a) 8 in let aux (i:nat{i < 8}) : Lemma (acc1.[i] == acc2.[i]) = assert (index (vec_v acc1.[i]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[i]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[i]) 0 == index (vec_v acc2.[i]) 0); eq_intro (vec_v acc1.[i]) (vec_v acc2.[i]); vecv_extensionality acc1.[i] acc2.[i] in Classical.forall_intro aux; eq_intro acc1 acc2 let lemma_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_256 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_256 b st } Spec.Agile.Hash.update SHA2_256 st b; (==) { Spec.SHA2.Lemmas.update_224_256 st b } Spec.Agile.Hash.update SHA2_224 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_224 b st } Hacl.Spec.SHA2.update SHA2_224 b st; } let lemma_spec_update_vec_224_256 b0 st0 : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_256 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_256 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_256 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_256 b0.(|0|) st0_m32; (==) { lemma_spec_update_224_256 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_224 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_224 #M32 b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update #SHA2_224 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update #SHA2_256 b0 st0) (SpecVec.update #SHA2_224 #M32 b0 st0) let lemma_spec_update_nblocks_vec_224_256 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0)) = let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let st1 = SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let b0_m32' = Seq.slice b0.(|0|) 0 (Seq.length b0.(|0|) - Seq.length b0.(|0|) % block_length SHA2_256) in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_256 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_256 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_256 (v len) b0.(|0|) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) st0_m32; (==) { FStar.Classical.forall_intro_2 lemma_spec_update_224_256; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) (Hacl.Spec.SHA2.update SHA2_224) st0_m32 } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) st0_m32; (==) { } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_224) (block_length SHA2_224) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) (st0_m32 <: words_state SHA2_224); (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_224 (v len) b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_224 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_224 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update_nblocks #SHA2_224 (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0) let lemma_spec_update_last_vec_224_256 totlen (len:size_t{v len <= block_length SHA2_256}) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0)) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let hacl_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) [ SMTPat (Hacl.Spec.SHA2.update SHA2_256 b st) ] = lemma_spec_update_224_256 b st in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_last #SHA2_256 totlen (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_256 #M32 totlen (v len) b0 st0 0 } Hacl.Spec.SHA2.update_last SHA2_256 totlen (v len) b0.(|0|) st0_m32; (==) { } Hacl.Spec.SHA2.update_last SHA2_224 totlen (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_224 #M32 totlen (v len) b0 st0 0 } (state_spec_v (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0) (SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0) let lemma_spec_update_384_512 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_512 b st == Hacl.Spec.SHA2.update SHA2_384 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_512 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_512 b st } Spec.Agile.Hash.update SHA2_512 st b; (==) { Spec.SHA2.Lemmas.update_384_512 st b } Spec.Agile.Hash.update SHA2_384 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_384 b st } Hacl.Spec.SHA2.update SHA2_384 b st; } let lemma_spec_update_vec_384_512 b0 st0 : Lemma (ensures SpecVec.update #SHA2_384 #M32 b0 st0 == SpecVec.update #SHA2_512 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_512 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_512 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_512 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_512 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_512 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_512 b0.(|0|) st0_m32; (==) { lemma_spec_update_384_512 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_384 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_384 #M32 b0 st0 0 } (state_spec_v #SHA2_384 #M32 (SpecVec.update #SHA2_384 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_512 (SpecVec.update #SHA2_512 b0 st0) (SpecVec.update #SHA2_384 #M32 b0 st0) let lemma_spec_update_nblocks_vec_384_512 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_512 #M32 (v len) b0 st0)) = let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; let st1 = SpecVec.update_nblocks #SHA2_512 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_512 in let b0_m32' = Seq.slice b0.(|0|) 0 (Seq.length b0.(|0|) - Seq.length b0.(|0|) % block_length SHA2_512) in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_512 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_nblocks #SHA2_512 (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_512 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_512 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_512 (v len) b0.(|0|) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_512) b0_m32' (Hacl.Spec.SHA2.update SHA2_512) st0_m32; (==) { FStar.Classical.forall_intro_2 lemma_spec_update_384_512; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_512) (block_length SHA2_512) b0_m32' (Hacl.Spec.SHA2.update SHA2_512) (Hacl.Spec.SHA2.update SHA2_384) st0_m32 } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_512) (block_length SHA2_512) b0_m32' (Hacl.Spec.SHA2.update SHA2_384) st0_m32; (==) { } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_384) (block_length SHA2_384) b0_m32' (Hacl.Spec.SHA2.update SHA2_384) (st0_m32 <: words_state SHA2_384); (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_384 (v len) b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_384 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_384 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_384 #M32 (SpecVec.update_nblocks #SHA2_384 (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_512 (SpecVec.update_nblocks #SHA2_512 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_384 #M32 (v len) b0 st0) let lemma_spec_update_last_vec_384_512 totlen (len:size_t{v len <= block_length SHA2_512}) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0 ==
false
false
Hacl.SHA2.Scalar32.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_spec_update_last_vec_384_512 (totlen: _) (len: size_t{v len <= block_length SHA2_512}) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_512 len; SpecVec.update_last #SHA2_384 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_512 #M32 totlen (v len) b0 st0))
[]
Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_last_vec_384_512
{ "file_name": "code/sha2-mb/Hacl.SHA2.Scalar32.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
totlen: Spec.Hash.Definitions.len_t Spec.Hash.Definitions.SHA2_384 -> len: Lib.IntTypes.size_t {Lib.IntTypes.v len <= Spec.Hash.Definitions.block_length Spec.Hash.Definitions.SHA2_512} -> b0: Hacl.Spec.SHA2.Vec.multiseq (Hacl.Spec.SHA2.Vec.lanes Spec.Hash.Definitions.SHA2_384 Hacl.Spec.SHA2.Vec.M32) (Lib.IntTypes.v len) -> st0: s: Lib.Sequence.seq (Hacl.Spec.SHA2.Vec.element_t Spec.Hash.Definitions.SHA2_512 Hacl.Spec.SHA2.Vec.M32) {FStar.Seq.Base.length s == 8 /\ FStar.Seq.Base.length s == 8} -> FStar.Pervasives.Lemma (ensures ([@@ FStar.Pervasives.inline_let ]let _ = Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t Spec.Hash.Definitions.SHA2_512 len in Hacl.Spec.SHA2.Vec.update_last totlen (Lib.IntTypes.v len) b0 st0 == Hacl.Spec.SHA2.Vec.update_last totlen (Lib.IntTypes.v len) b0 st0))
{ "end_col": 64, "end_line": 253, "start_col": 4, "start_line": 227 }
FStar.Pervasives.Lemma
val lemma_spec_update_nblocks_vec_224_256 (len: size_t) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0))
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_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_spec_update_nblocks_vec_224_256 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0)) = let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let st1 = SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let b0_m32' = Seq.slice b0.(|0|) 0 (Seq.length b0.(|0|) - Seq.length b0.(|0|) % block_length SHA2_256) in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_256 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_256 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_256 (v len) b0.(|0|) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) st0_m32; (==) { FStar.Classical.forall_intro_2 lemma_spec_update_224_256; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) (Hacl.Spec.SHA2.update SHA2_224) st0_m32 } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) st0_m32; (==) { } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_224) (block_length SHA2_224) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) (st0_m32 <: words_state SHA2_224); (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_224 (v len) b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_224 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_224 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update_nblocks #SHA2_224 (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0)
val lemma_spec_update_nblocks_vec_224_256 (len: size_t) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0)) let lemma_spec_update_nblocks_vec_224_256 (len: size_t) b0 st0 : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0)) =
false
null
true
let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let st1 = SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[ 0 ] <: words_state SHA2_256 in let b0_m32' = Seq.slice b0.(| 0 |) 0 (Seq.length b0.(| 0 |) - Seq.length b0.(| 0 |) % block_length SHA2_256) in let st1_m32 = (state_spec_v st1).[ 0 ] <: words_state SHA2_256 in calc ( == ) { st1_m32; ( == ) { () } (state_spec_v (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0)).[ 0 ]; ( == ) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_256 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_256 (v len) b0.(| 0 |) st0_m32; ( == ) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_256 (v len) b0.(| 0 |) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) st0_m32; ( == ) { (FStar.Classical.forall_intro_2 lemma_spec_update_224_256; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) (Hacl.Spec.SHA2.update SHA2_224) st0_m32) } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) st0_m32; ( == ) { () } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_224) (block_length SHA2_224) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) (st0_m32 <: words_state SHA2_224); ( == ) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_224 (v len) b0.(| 0 |) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_224 (v len) b0.(| 0 |) st0_m32; ( == ) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_224 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update_nblocks #SHA2_224 (v len) b0 st0)).[ 0 ]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0)
{ "checked_file": "Hacl.SHA2.Scalar32.Lemmas.fst.checked", "dependencies": [ "Spec.SHA2.Lemmas.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.EquivScalar.fsti.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Scalar32.Lemmas.fst" }
[ "lemma" ]
[ "Lib.IntTypes.size_t", "Hacl.Spec.SHA2.Vec.multiseq", "Hacl.Spec.SHA2.Vec.lanes", "Spec.Hash.Definitions.SHA2_224", "Hacl.Spec.SHA2.Vec.M32", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Sequence.seq", "Hacl.Spec.SHA2.Vec.element_t", "Spec.Hash.Definitions.SHA2_256", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Hacl.SHA2.Scalar32.Lemmas.state_spec_v_extensionality", "Hacl.Spec.SHA2.Vec.update_nblocks", "Prims.unit", "FStar.Calc.calc_finish", "Spec.Hash.Definitions.words_state", "Lib.Sequence.op_String_Access", "Hacl.Spec.SHA2.Vec.words_state'", "Hacl.Spec.SHA2.Vec.state_spec_v", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Hacl.Spec.SHA2.update_nblocks", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "Lib.Sequence.repeat_blocks_multi", "Spec.Hash.Definitions.block_length", "Hacl.Spec.SHA2.update", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l", "Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi", "Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality", "FStar.Classical.forall_intro_2", "Spec.Hash.Definitions.word", "Spec.Hash.Definitions.state_word_length", "Prims.l_or", "Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_224_256", "FStar.Seq.Base.seq", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "FStar.Seq.Base.slice", "Prims.op_Subtraction", "Prims.op_Modulus", "Hacl.Spec.SHA2.Vec.state_spec", "Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t", "Prims.l_True", "FStar.Pervasives.pattern" ]
[]
module Hacl.SHA2.Scalar32.Lemmas open Lib.IntTypes open Spec.Agile.Hash open Hacl.Spec.SHA2.Vec module SpecVec = Hacl.Spec.SHA2.Vec #push-options "--fuel 0 --ifuel 0 --z3rlimit 50" let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) = let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[0] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[0] <: lseq (word a) 8 in let aux (i:nat{i < 8}) : Lemma (acc1.[i] == acc2.[i]) = assert (index (vec_v acc1.[i]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[i]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[i]) 0 == index (vec_v acc2.[i]) 0); eq_intro (vec_v acc1.[i]) (vec_v acc2.[i]); vecv_extensionality acc1.[i] acc2.[i] in Classical.forall_intro aux; eq_intro acc1 acc2 let lemma_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_256 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_256 b st } Spec.Agile.Hash.update SHA2_256 st b; (==) { Spec.SHA2.Lemmas.update_224_256 st b } Spec.Agile.Hash.update SHA2_224 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_224 b st } Hacl.Spec.SHA2.update SHA2_224 b st; } let lemma_spec_update_vec_224_256 b0 st0 : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_256 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_256 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_256 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_256 b0.(|0|) st0_m32; (==) { lemma_spec_update_224_256 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_224 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_224 #M32 b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update #SHA2_224 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update #SHA2_256 b0 st0) (SpecVec.update #SHA2_224 #M32 b0 st0) let lemma_spec_update_nblocks_vec_224_256 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 ==
false
false
Hacl.SHA2.Scalar32.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_spec_update_nblocks_vec_224_256 (len: size_t) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0))
[]
Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_nblocks_vec_224_256
{ "file_name": "code/sha2-mb/Hacl.SHA2.Scalar32.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t -> b0: Hacl.Spec.SHA2.Vec.multiseq (Hacl.Spec.SHA2.Vec.lanes Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M32) (Lib.IntTypes.v len) -> st0: s: Lib.Sequence.seq (Hacl.Spec.SHA2.Vec.element_t Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M32) {FStar.Seq.Base.length s == 8 /\ FStar.Seq.Base.length s == 8} -> FStar.Pervasives.Lemma (ensures ([@@ FStar.Pervasives.inline_let ]let _ = Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t Spec.Hash.Definitions.SHA2_256 len in Hacl.Spec.SHA2.Vec.update_nblocks (Lib.IntTypes.v len) b0 st0 == Hacl.Spec.SHA2.Vec.update_nblocks (Lib.IntTypes.v len) b0 st0))
{ "end_col": 60, "end_line": 111, "start_col": 4, "start_line": 78 }
FStar.Pervasives.Lemma
val lemma_spec_update_last_vec_224_256 (totlen: _) (len: size_t{v len <= block_length SHA2_256}) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0))
[ { "abbrev": true, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": "SpecVec" }, { "abbrev": false, "full_module": "Hacl.Spec.SHA2.Vec", "short_module": null }, { "abbrev": false, "full_module": "Spec.Agile.Hash", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_module": "Hacl.SHA2.Scalar32", "short_module": null }, { "abbrev": false, "full_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_spec_update_last_vec_224_256 totlen (len:size_t{v len <= block_length SHA2_256}) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0)) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let hacl_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) [ SMTPat (Hacl.Spec.SHA2.update SHA2_256 b st) ] = lemma_spec_update_224_256 b st in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_last #SHA2_256 totlen (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_256 #M32 totlen (v len) b0 st0 0 } Hacl.Spec.SHA2.update_last SHA2_256 totlen (v len) b0.(|0|) st0_m32; (==) { } Hacl.Spec.SHA2.update_last SHA2_224 totlen (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_224 #M32 totlen (v len) b0 st0 0 } (state_spec_v (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0) (SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0)
val lemma_spec_update_last_vec_224_256 (totlen: _) (len: size_t{v len <= block_length SHA2_256}) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0)) let lemma_spec_update_last_vec_224_256 totlen (len: size_t{v len <= block_length SHA2_256}) b0 st0 : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0)) =
false
null
true
let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[ 0 ] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[ 0 ] <: words_state SHA2_256 in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let hacl_spec_update_224_256 b st : Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) [SMTPat (Hacl.Spec.SHA2.update SHA2_256 b st)] = lemma_spec_update_224_256 b st in calc ( == ) { st1_m32; ( == ) { () } (state_spec_v (SpecVec.update_last #SHA2_256 totlen (v len) b0 st0)).[ 0 ]; ( == ) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_256 #M32 totlen (v len) b0 st0 0 } Hacl.Spec.SHA2.update_last SHA2_256 totlen (v len) b0.(| 0 |) st0_m32; ( == ) { () } Hacl.Spec.SHA2.update_last SHA2_224 totlen (v len) b0.(| 0 |) st0_m32; ( == ) { Hacl.Spec.SHA2.Equiv.update_last_lemma_l #SHA2_224 #M32 totlen (v len) b0 st0 0 } (state_spec_v (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0)).[ 0 ]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0) (SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0)
{ "checked_file": "Hacl.SHA2.Scalar32.Lemmas.fst.checked", "dependencies": [ "Spec.SHA2.Lemmas.fsti.checked", "Spec.Agile.Hash.fsti.checked", "prims.fst.checked", "Lib.Sequence.Lemmas.fsti.checked", "Lib.Sequence.fsti.checked", "Lib.MultiBuffer.fst.checked", "Lib.IntVector.fsti.checked", "Lib.IntTypes.fsti.checked", "Hacl.Spec.SHA2.Vec.fst.checked", "Hacl.Spec.SHA2.EquivScalar.fsti.checked", "Hacl.Spec.SHA2.Equiv.fst.checked", "Hacl.Spec.SHA2.fst.checked", "Hacl.Impl.SHA2.Core.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Classical.fsti.checked", "FStar.Calc.fsti.checked" ], "interface_file": false, "source_file": "Hacl.SHA2.Scalar32.Lemmas.fst" }
[ "lemma" ]
[ "Spec.Hash.Definitions.len_t", "Spec.Hash.Definitions.SHA2_224", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Spec.Hash.Definitions.block_length", "Spec.Hash.Definitions.SHA2_256", "Hacl.Spec.SHA2.Vec.multiseq", "Hacl.Spec.SHA2.Vec.lanes", "Hacl.Spec.SHA2.Vec.M32", "Lib.Sequence.seq", "Hacl.Spec.SHA2.Vec.element_t", "Prims.l_and", "Prims.eq2", "Prims.nat", "FStar.Seq.Base.length", "Hacl.SHA2.Scalar32.Lemmas.state_spec_v_extensionality", "Hacl.Spec.SHA2.Vec.update_last", "Prims.unit", "FStar.Calc.calc_finish", "Spec.Hash.Definitions.words_state", "Lib.Sequence.op_String_Access", "Hacl.Spec.SHA2.Vec.words_state'", "Hacl.Spec.SHA2.Vec.state_spec_v", "Prims.Cons", "FStar.Preorder.relation", "Prims.Nil", "FStar.Calc.calc_step", "Hacl.Spec.SHA2.update_last", "Lib.MultiBuffer.op_Lens_Access", "FStar.Seq.Properties.lseq", "Lib.IntTypes.uint8", "FStar.Calc.calc_init", "FStar.Calc.calc_pack", "Prims.squash", "Hacl.Spec.SHA2.Equiv.update_last_lemma_l", "Lib.IntTypes.int_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Hash.Definitions.word", "Spec.Hash.Definitions.state_word_length", "Prims.l_True", "Prims.l_or", "Hacl.Spec.SHA2.update", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_224_256", "Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t", "Hacl.Spec.SHA2.Vec.state_spec" ]
[]
module Hacl.SHA2.Scalar32.Lemmas open Lib.IntTypes open Spec.Agile.Hash open Hacl.Spec.SHA2.Vec module SpecVec = Hacl.Spec.SHA2.Vec #push-options "--fuel 0 --ifuel 0 --z3rlimit 50" let state_spec_v_extensionality (a : hash_alg { is_sha2 a }) (acc1: Hacl.Spec.SHA2.Vec.(state_spec a M32)) (acc2: Hacl.Spec.SHA2.Vec.(state_spec a M32)) : Lemma (requires (let open Hacl.Spec.SHA2.Vec in Lib.Sequence.index (state_spec_v acc1) 0 == Lib.Sequence.index (state_spec_v acc2) 0)) (ensures acc1 == acc2) = let open Lib.Sequence in let open Lib.IntVector in let open Hacl.Spec.SHA2.Vec in allow_inversion hash_alg; let acc1_s = (state_spec_v acc1).[0] <: lseq (word a) 8 in let acc2_s = (state_spec_v acc2).[0] <: lseq (word a) 8 in let aux (i:nat{i < 8}) : Lemma (acc1.[i] == acc2.[i]) = assert (index (vec_v acc1.[i]) 0 == index #(word a) #8 acc1_s i); assert (index (vec_v acc2.[i]) 0 == index #(word a) #8 acc2_s i); assert (index (vec_v acc1.[i]) 0 == index (vec_v acc2.[i]) 0); eq_intro (vec_v acc1.[i]) (vec_v acc2.[i]); vecv_extensionality acc1.[i] acc2.[i] in Classical.forall_intro aux; eq_intro acc1 acc2 let lemma_spec_update_224_256 b st: Lemma (ensures Hacl.Spec.SHA2.update SHA2_256 b st == Hacl.Spec.SHA2.update SHA2_224 b st) = calc (==) { Hacl.Spec.SHA2.update SHA2_256 b st; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_256 b st } Spec.Agile.Hash.update SHA2_256 st b; (==) { Spec.SHA2.Lemmas.update_224_256 st b } Spec.Agile.Hash.update SHA2_224 st b; (==) { Hacl.Spec.SHA2.EquivScalar.update_lemma SHA2_224 b st } Hacl.Spec.SHA2.update SHA2_224 b st; } let lemma_spec_update_vec_224_256 b0 st0 : Lemma (ensures SpecVec.update #SHA2_224 #M32 b0 st0 == SpecVec.update #SHA2_256 #M32 b0 st0) = let open Lib.Sequence in let open Lib.MultiBuffer in let st1 = SpecVec.update #SHA2_256 #M32 b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update #SHA2_256 b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_256 #M32 b0 st0 0 } Hacl.Spec.SHA2.update SHA2_256 b0.(|0|) st0_m32; (==) { lemma_spec_update_224_256 b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update SHA2_224 b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_lemma_l #SHA2_224 #M32 b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update #SHA2_224 b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update #SHA2_256 b0 st0) (SpecVec.update #SHA2_224 #M32 b0 st0) let lemma_spec_update_nblocks_vec_224_256 (len:size_t) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0 == SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0)) = let open Lib.IntTypes in let open Lib.Sequence in let open Lib.MultiBuffer in Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; let st1 = SpecVec.update_nblocks #SHA2_256 #M32 (v len) b0 st0 in let st0_m32 = (state_spec_v st0).[0] <: words_state SHA2_256 in let b0_m32' = Seq.slice b0.(|0|) 0 (Seq.length b0.(|0|) - Seq.length b0.(|0|) % block_length SHA2_256) in let st1_m32 = (state_spec_v st1).[0] <: words_state SHA2_256 in calc (==) { st1_m32; (==) {} (state_spec_v (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0)).[0]; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_256 #M32 (v len) b0 st0 0 } Hacl.Spec.SHA2.update_nblocks SHA2_256 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_256 (v len) b0.(|0|) st0_m32 } Lib.Sequence.repeat_blocks_multi (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) st0_m32; (==) { FStar.Classical.forall_intro_2 lemma_spec_update_224_256; Lib.Sequence.Lemmas.repeat_blocks_multi_extensionality #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_256) (Hacl.Spec.SHA2.update SHA2_224) st0_m32 } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_256) (block_length SHA2_256) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) st0_m32; (==) { } Lib.Sequence.repeat_blocks_multi #uint8 #(words_state SHA2_224) (block_length SHA2_224) b0_m32' (Hacl.Spec.SHA2.update SHA2_224) (st0_m32 <: words_state SHA2_224); (==) { Hacl.Spec.SHA2.EquivScalar.update_nblocks_is_repeat_blocks_multi SHA2_224 (v len) b0.(|0|) st0_m32 } Hacl.Spec.SHA2.update_nblocks SHA2_224 (v len) b0.(|0|) st0_m32; (==) { Hacl.Spec.SHA2.Equiv.update_nblocks_lemma_l #SHA2_224 #M32 (v len) b0 st0 0 } (state_spec_v #SHA2_224 #M32 (SpecVec.update_nblocks #SHA2_224 (v len) b0 st0)).[0]; }; state_spec_v_extensionality SHA2_256 (SpecVec.update_nblocks #SHA2_256 (v len) b0 st0) (SpecVec.update_nblocks #SHA2_224 #M32 (v len) b0 st0) let lemma_spec_update_last_vec_224_256 totlen (len:size_t{v len <= block_length SHA2_256}) b0 st0 : Lemma (ensures ( Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 ==
false
false
Hacl.SHA2.Scalar32.Lemmas.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_spec_update_last_vec_224_256 (totlen: _) (len: size_t{v len <= block_length SHA2_256}) (b0 st0: _) : Lemma (ensures (Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t SHA2_256 len; SpecVec.update_last #SHA2_224 #M32 totlen (v len) b0 st0 == SpecVec.update_last #SHA2_256 #M32 totlen (v len) b0 st0))
[]
Hacl.SHA2.Scalar32.Lemmas.lemma_spec_update_last_vec_224_256
{ "file_name": "code/sha2-mb/Hacl.SHA2.Scalar32.Lemmas.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
totlen: Spec.Hash.Definitions.len_t Spec.Hash.Definitions.SHA2_224 -> len: Lib.IntTypes.size_t {Lib.IntTypes.v len <= Spec.Hash.Definitions.block_length Spec.Hash.Definitions.SHA2_256} -> b0: Hacl.Spec.SHA2.Vec.multiseq (Hacl.Spec.SHA2.Vec.lanes Spec.Hash.Definitions.SHA2_224 Hacl.Spec.SHA2.Vec.M32) (Lib.IntTypes.v len) -> st0: s: Lib.Sequence.seq (Hacl.Spec.SHA2.Vec.element_t Spec.Hash.Definitions.SHA2_256 Hacl.Spec.SHA2.Vec.M32) {FStar.Seq.Base.length s == 8 /\ FStar.Seq.Base.length s == 8} -> FStar.Pervasives.Lemma (ensures ([@@ FStar.Pervasives.inline_let ]let _ = Hacl.Impl.SHA2.Core.lemma_len_lt_max_a_fits_size_t Spec.Hash.Definitions.SHA2_256 len in Hacl.Spec.SHA2.Vec.update_last totlen (Lib.IntTypes.v len) b0 st0 == Hacl.Spec.SHA2.Vec.update_last totlen (Lib.IntTypes.v len) b0 st0))
{ "end_col": 64, "end_line": 143, "start_col": 4, "start_line": 117 }
Prims.Tot
val frodo_unpack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_unpack_state #n1 #n2 i = lseq uint16 (8 * i)
val frodo_unpack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_unpack_state #n1 #n2 i =
false
null
false
lseq uint16 (8 * i)
{ "checked_file": "Spec.Frodo.Pack.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Pack.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Lib.Sequence.lseq", "Lib.IntTypes.uint16" ]
[]
module Spec.Frodo.Pack open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix module Seq = Lib.Sequence module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar +FStar.Pervasives +FStar.UInt -Spec +Spec.Frodo +Spec.Frodo.Params +Spec.Matrix'" /// Pack val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d let frodo_pack8 d a = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let a0 = Seq.index a 0 &. maskd in let a1 = Seq.index a 1 &. maskd in let a2 = Seq.index a 2 &. maskd in let a3 = Seq.index a 3 &. maskd in let a4 = Seq.index a 4 &. maskd in let a5 = Seq.index a 5 &. maskd in let a6 = Seq.index a 6 &. maskd in let a7 = Seq.index a 7 &. maskd in let templong = to_u128 a0 <<. size (7 * d) |. to_u128 a1 <<. size (6 * d) |. to_u128 a2 <<. size (5 * d) |. to_u128 a3 <<. size (4 * d) |. to_u128 a4 <<. size (3 * d) |. to_u128 a5 <<. size (2 * d) |. to_u128 a6 <<. size (1 * d) |. to_u128 a7 <<. size (0 * d) in let v16 = uint_to_bytes_be templong in Seq.sub v16 (16 - d) d val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_pack_state #n1 #n2 d i = lseq uint8 (d * i) val frodo_pack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> i:size_nat{i < (n1 * n2) / 8} -> frodo_pack_state #n1 #n2 d i -> frodo_pack_state #n1 #n2 d (i + 1) let frodo_pack_inner #n1 #n2 d a i s = s @| frodo_pack8 d (Seq.sub a (8 * i) 8) val frodo_pack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> lbytes (d * ((n1 * n2) / 8)) let frodo_pack #n1 #n2 d a = Loops.repeat_gen ((n1 * n2) / 8) (frodo_pack_state #n1 #n2 d) (frodo_pack_inner #n1 #n2 d a) (Seq.create 0 (u8 0)) /// Unpack val frodo_unpack8: d:size_nat{d <= 16} -> b:lbytes d -> lseq uint16 8 let frodo_unpack8 d b = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let v16 = Seq.create 16 (u8 0) in let src = update_sub v16 (16 - d) d b in let templong: uint_t U128 SEC = uint_from_bytes_be src in let res = Seq.create 8 (u16 0) in let res = res.[0] <- to_u16 (templong >>. size (7 * d)) &. maskd in let res = res.[1] <- to_u16 (templong >>. size (6 * d)) &. maskd in let res = res.[2] <- to_u16 (templong >>. size (5 * d)) &. maskd in let res = res.[3] <- to_u16 (templong >>. size (4 * d)) &. maskd in let res = res.[4] <- to_u16 (templong >>. size (3 * d)) &. maskd in let res = res.[5] <- to_u16 (templong >>. size (2 * d)) &. maskd in let res = res.[6] <- to_u16 (templong >>. size (1 * d)) &. maskd in let res = res.[7] <- to_u16 (templong >>. size (0 * d)) &. maskd in res val frodo_unpack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> i:size_nat{i <= (n1 * n2) / 8}
false
false
Spec.Frodo.Pack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_unpack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0
[]
Spec.Frodo.Pack.frodo_unpack_state
{ "file_name": "specs/frodo/Spec.Frodo.Pack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Lib.IntTypes.size_nat{i <= n1 * n2 / 8} -> Type0
{ "end_col": 54, "end_line": 102, "start_col": 35, "start_line": 102 }
Prims.Tot
val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_pack_state #n1 #n2 d i = lseq uint8 (d * i)
val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_pack_state #n1 #n2 d i =
false
null
false
lseq uint8 (d * i)
{ "checked_file": "Spec.Frodo.Pack.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Pack.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Lib.Sequence.lseq", "Lib.IntTypes.uint8" ]
[]
module Spec.Frodo.Pack open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix module Seq = Lib.Sequence module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar +FStar.Pervasives +FStar.UInt -Spec +Spec.Frodo +Spec.Frodo.Params +Spec.Matrix'" /// Pack val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d let frodo_pack8 d a = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let a0 = Seq.index a 0 &. maskd in let a1 = Seq.index a 1 &. maskd in let a2 = Seq.index a 2 &. maskd in let a3 = Seq.index a 3 &. maskd in let a4 = Seq.index a 4 &. maskd in let a5 = Seq.index a 5 &. maskd in let a6 = Seq.index a 6 &. maskd in let a7 = Seq.index a 7 &. maskd in let templong = to_u128 a0 <<. size (7 * d) |. to_u128 a1 <<. size (6 * d) |. to_u128 a2 <<. size (5 * d) |. to_u128 a3 <<. size (4 * d) |. to_u128 a4 <<. size (3 * d) |. to_u128 a5 <<. size (2 * d) |. to_u128 a6 <<. size (1 * d) |. to_u128 a7 <<. size (0 * d) in let v16 = uint_to_bytes_be templong in Seq.sub v16 (16 - d) d val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8}
false
false
Spec.Frodo.Pack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0
[]
Spec.Frodo.Pack.frodo_pack_state
{ "file_name": "specs/frodo/Spec.Frodo.Pack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d: Lib.IntTypes.size_nat{d * (n1 * n2 / 8) <= Lib.IntTypes.max_size_t /\ d <= 16} -> i: Lib.IntTypes.size_nat{i <= n1 * n2 / 8} -> Type0
{ "end_col": 53, "end_line": 50, "start_col": 35, "start_line": 50 }
Prims.Tot
val frodo_pack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> lbytes (d * ((n1 * n2) / 8))
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_pack #n1 #n2 d a = Loops.repeat_gen ((n1 * n2) / 8) (frodo_pack_state #n1 #n2 d) (frodo_pack_inner #n1 #n2 d a) (Seq.create 0 (u8 0))
val frodo_pack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> lbytes (d * ((n1 * n2) / 8)) let frodo_pack #n1 #n2 d a =
false
null
false
Loops.repeat_gen ((n1 * n2) / 8) (frodo_pack_state #n1 #n2 d) (frodo_pack_inner #n1 #n2 d a) (Seq.create 0 (u8 0))
{ "checked_file": "Spec.Frodo.Pack.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Pack.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Spec.Matrix.matrix", "Lib.LoopCombinators.repeat_gen", "Spec.Frodo.Pack.frodo_pack_state", "Spec.Frodo.Pack.frodo_pack_inner", "Lib.Sequence.create", "Lib.IntTypes.uint8", "Lib.IntTypes.u8", "Lib.ByteSequence.lbytes" ]
[]
module Spec.Frodo.Pack open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix module Seq = Lib.Sequence module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar +FStar.Pervasives +FStar.UInt -Spec +Spec.Frodo +Spec.Frodo.Params +Spec.Matrix'" /// Pack val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d let frodo_pack8 d a = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let a0 = Seq.index a 0 &. maskd in let a1 = Seq.index a 1 &. maskd in let a2 = Seq.index a 2 &. maskd in let a3 = Seq.index a 3 &. maskd in let a4 = Seq.index a 4 &. maskd in let a5 = Seq.index a 5 &. maskd in let a6 = Seq.index a 6 &. maskd in let a7 = Seq.index a 7 &. maskd in let templong = to_u128 a0 <<. size (7 * d) |. to_u128 a1 <<. size (6 * d) |. to_u128 a2 <<. size (5 * d) |. to_u128 a3 <<. size (4 * d) |. to_u128 a4 <<. size (3 * d) |. to_u128 a5 <<. size (2 * d) |. to_u128 a6 <<. size (1 * d) |. to_u128 a7 <<. size (0 * d) in let v16 = uint_to_bytes_be templong in Seq.sub v16 (16 - d) d val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_pack_state #n1 #n2 d i = lseq uint8 (d * i) val frodo_pack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> i:size_nat{i < (n1 * n2) / 8} -> frodo_pack_state #n1 #n2 d i -> frodo_pack_state #n1 #n2 d (i + 1) let frodo_pack_inner #n1 #n2 d a i s = s @| frodo_pack8 d (Seq.sub a (8 * i) 8) val frodo_pack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> lbytes (d * ((n1 * n2) / 8))
false
false
Spec.Frodo.Pack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_pack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> lbytes (d * ((n1 * n2) / 8))
[]
Spec.Frodo.Pack.frodo_pack
{ "file_name": "specs/frodo/Spec.Frodo.Pack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d: Lib.IntTypes.size_nat{d * (n1 * n2 / 8) <= Lib.IntTypes.max_size_t /\ d <= 16} -> a: Spec.Matrix.matrix n1 n2 -> Lib.ByteSequence.lbytes (d * (n1 * n2 / 8))
{ "end_col": 25, "end_line": 73, "start_col": 2, "start_line": 70 }
Prims.Tot
val frodo_unpack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> lbytes (d * ((n1 * n2) / 8)) -> matrix n1 n2
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_unpack #n1 #n2 d b = Loops.repeat_gen ((n1 * n2) / 8) (frodo_unpack_state #n1 #n2) (frodo_unpack_inner #n1 #n2 d b) FStar.Seq.empty
val frodo_unpack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> lbytes (d * ((n1 * n2) / 8)) -> matrix n1 n2 let frodo_unpack #n1 #n2 d b =
false
null
false
Loops.repeat_gen ((n1 * n2) / 8) (frodo_unpack_state #n1 #n2) (frodo_unpack_inner #n1 #n2 d b) FStar.Seq.empty
{ "checked_file": "Spec.Frodo.Pack.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Pack.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Lib.ByteSequence.lbytes", "Lib.LoopCombinators.repeat_gen", "Spec.Frodo.Pack.frodo_unpack_state", "Spec.Frodo.Pack.frodo_unpack_inner", "FStar.Seq.Base.empty", "Lib.IntTypes.uint16", "Spec.Matrix.matrix" ]
[]
module Spec.Frodo.Pack open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix module Seq = Lib.Sequence module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar +FStar.Pervasives +FStar.UInt -Spec +Spec.Frodo +Spec.Frodo.Params +Spec.Matrix'" /// Pack val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d let frodo_pack8 d a = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let a0 = Seq.index a 0 &. maskd in let a1 = Seq.index a 1 &. maskd in let a2 = Seq.index a 2 &. maskd in let a3 = Seq.index a 3 &. maskd in let a4 = Seq.index a 4 &. maskd in let a5 = Seq.index a 5 &. maskd in let a6 = Seq.index a 6 &. maskd in let a7 = Seq.index a 7 &. maskd in let templong = to_u128 a0 <<. size (7 * d) |. to_u128 a1 <<. size (6 * d) |. to_u128 a2 <<. size (5 * d) |. to_u128 a3 <<. size (4 * d) |. to_u128 a4 <<. size (3 * d) |. to_u128 a5 <<. size (2 * d) |. to_u128 a6 <<. size (1 * d) |. to_u128 a7 <<. size (0 * d) in let v16 = uint_to_bytes_be templong in Seq.sub v16 (16 - d) d val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_pack_state #n1 #n2 d i = lseq uint8 (d * i) val frodo_pack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> i:size_nat{i < (n1 * n2) / 8} -> frodo_pack_state #n1 #n2 d i -> frodo_pack_state #n1 #n2 d (i + 1) let frodo_pack_inner #n1 #n2 d a i s = s @| frodo_pack8 d (Seq.sub a (8 * i) 8) val frodo_pack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> lbytes (d * ((n1 * n2) / 8)) let frodo_pack #n1 #n2 d a = Loops.repeat_gen ((n1 * n2) / 8) (frodo_pack_state #n1 #n2 d) (frodo_pack_inner #n1 #n2 d a) (Seq.create 0 (u8 0)) /// Unpack val frodo_unpack8: d:size_nat{d <= 16} -> b:lbytes d -> lseq uint16 8 let frodo_unpack8 d b = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let v16 = Seq.create 16 (u8 0) in let src = update_sub v16 (16 - d) d b in let templong: uint_t U128 SEC = uint_from_bytes_be src in let res = Seq.create 8 (u16 0) in let res = res.[0] <- to_u16 (templong >>. size (7 * d)) &. maskd in let res = res.[1] <- to_u16 (templong >>. size (6 * d)) &. maskd in let res = res.[2] <- to_u16 (templong >>. size (5 * d)) &. maskd in let res = res.[3] <- to_u16 (templong >>. size (4 * d)) &. maskd in let res = res.[4] <- to_u16 (templong >>. size (3 * d)) &. maskd in let res = res.[5] <- to_u16 (templong >>. size (2 * d)) &. maskd in let res = res.[6] <- to_u16 (templong >>. size (1 * d)) &. maskd in let res = res.[7] <- to_u16 (templong >>. size (0 * d)) &. maskd in res val frodo_unpack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_unpack_state #n1 #n2 i = lseq uint16 (8 * i) val frodo_unpack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> b:lbytes (d * ((n1 * n2) / 8)) -> i:size_nat{i < (n1 * n2) / 8} -> frodo_unpack_state #n1 #n2 i -> frodo_unpack_state #n1 #n2 (i + 1) let frodo_unpack_inner #n1 #n2 d b i s = s @| frodo_unpack8 d (Seq.sub b (d * i) d) val frodo_unpack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> lbytes (d * ((n1 * n2) / 8)) -> matrix n1 n2
false
false
Spec.Frodo.Pack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_unpack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> lbytes (d * ((n1 * n2) / 8)) -> matrix n1 n2
[]
Spec.Frodo.Pack.frodo_unpack
{ "file_name": "specs/frodo/Spec.Frodo.Pack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d: Lib.IntTypes.size_nat{d * (n1 * n2 / 8) <= Lib.IntTypes.max_size_t /\ d <= 16} -> b: Lib.ByteSequence.lbytes (d * (n1 * n2 / 8)) -> Spec.Matrix.matrix n1 n2
{ "end_col": 19, "end_line": 125, "start_col": 2, "start_line": 122 }
Prims.Tot
val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_pack8 d a = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let a0 = Seq.index a 0 &. maskd in let a1 = Seq.index a 1 &. maskd in let a2 = Seq.index a 2 &. maskd in let a3 = Seq.index a 3 &. maskd in let a4 = Seq.index a 4 &. maskd in let a5 = Seq.index a 5 &. maskd in let a6 = Seq.index a 6 &. maskd in let a7 = Seq.index a 7 &. maskd in let templong = to_u128 a0 <<. size (7 * d) |. to_u128 a1 <<. size (6 * d) |. to_u128 a2 <<. size (5 * d) |. to_u128 a3 <<. size (4 * d) |. to_u128 a4 <<. size (3 * d) |. to_u128 a5 <<. size (2 * d) |. to_u128 a6 <<. size (1 * d) |. to_u128 a7 <<. size (0 * d) in let v16 = uint_to_bytes_be templong in Seq.sub v16 (16 - d) d
val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d let frodo_pack8 d a =
false
null
false
let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let a0 = Seq.index a 0 &. maskd in let a1 = Seq.index a 1 &. maskd in let a2 = Seq.index a 2 &. maskd in let a3 = Seq.index a 3 &. maskd in let a4 = Seq.index a 4 &. maskd in let a5 = Seq.index a 5 &. maskd in let a6 = Seq.index a 6 &. maskd in let a7 = Seq.index a 7 &. maskd in let templong = to_u128 a0 <<. size (7 * d) |. to_u128 a1 <<. size (6 * d) |. to_u128 a2 <<. size (5 * d) |. to_u128 a3 <<. size (4 * d) |. to_u128 a4 <<. size (3 * d) |. to_u128 a5 <<. size (2 * d) |. to_u128 a6 <<. size (1 * d) |. to_u128 a7 <<. size (0 * d) in let v16 = uint_to_bytes_be templong in Seq.sub v16 (16 - d) d
{ "checked_file": "Spec.Frodo.Pack.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Pack.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.Sequence.lseq", "Lib.IntTypes.uint16", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.IntTypes.numbytes", "Lib.IntTypes.U128", "Prims.op_Subtraction", "Lib.IntTypes.int_t", "Lib.ByteSequence.uint_to_bytes_be", "Lib.IntTypes.op_Bar_Dot", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.to_u128", "Lib.IntTypes.U16", "Lib.IntTypes.size", "FStar.Mul.op_Star", "Lib.IntTypes.op_Amp_Dot", "Lib.Sequence.index", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.to_u16", "Lib.IntTypes.U32", "Lib.IntTypes.u32", "Lib.IntTypes.u16", "Lib.ByteSequence.lbytes" ]
[]
module Spec.Frodo.Pack open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix module Seq = Lib.Sequence module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar +FStar.Pervasives +FStar.UInt -Spec +Spec.Frodo +Spec.Frodo.Params +Spec.Matrix'" /// Pack val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8
false
false
Spec.Frodo.Pack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d
[]
Spec.Frodo.Pack.frodo_pack8
{ "file_name": "specs/frodo/Spec.Frodo.Pack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d: Lib.IntTypes.size_nat{d <= 16} -> a: Lib.Sequence.lseq Lib.IntTypes.uint16 8 -> Lib.ByteSequence.lbytes d
{ "end_col": 24, "end_line": 42, "start_col": 21, "start_line": 21 }
Prims.Tot
val frodo_pack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> i:size_nat{i < (n1 * n2) / 8} -> frodo_pack_state #n1 #n2 d i -> frodo_pack_state #n1 #n2 d (i + 1)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_pack_inner #n1 #n2 d a i s = s @| frodo_pack8 d (Seq.sub a (8 * i) 8)
val frodo_pack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> i:size_nat{i < (n1 * n2) / 8} -> frodo_pack_state #n1 #n2 d i -> frodo_pack_state #n1 #n2 d (i + 1) let frodo_pack_inner #n1 #n2 d a i s =
false
null
false
s @| frodo_pack8 d (Seq.sub a (8 * i) 8)
{ "checked_file": "Spec.Frodo.Pack.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Pack.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Spec.Matrix.matrix", "Prims.op_LessThan", "Spec.Frodo.Pack.frodo_pack_state", "Lib.Sequence.op_At_Bar", "Lib.IntTypes.uint8", "Spec.Frodo.Pack.frodo_pack8", "Lib.Sequence.sub", "Spec.Matrix.elem", "Prims.op_Addition" ]
[]
module Spec.Frodo.Pack open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix module Seq = Lib.Sequence module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar +FStar.Pervasives +FStar.UInt -Spec +Spec.Frodo +Spec.Frodo.Params +Spec.Matrix'" /// Pack val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d let frodo_pack8 d a = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let a0 = Seq.index a 0 &. maskd in let a1 = Seq.index a 1 &. maskd in let a2 = Seq.index a 2 &. maskd in let a3 = Seq.index a 3 &. maskd in let a4 = Seq.index a 4 &. maskd in let a5 = Seq.index a 5 &. maskd in let a6 = Seq.index a 6 &. maskd in let a7 = Seq.index a 7 &. maskd in let templong = to_u128 a0 <<. size (7 * d) |. to_u128 a1 <<. size (6 * d) |. to_u128 a2 <<. size (5 * d) |. to_u128 a3 <<. size (4 * d) |. to_u128 a4 <<. size (3 * d) |. to_u128 a5 <<. size (2 * d) |. to_u128 a6 <<. size (1 * d) |. to_u128 a7 <<. size (0 * d) in let v16 = uint_to_bytes_be templong in Seq.sub v16 (16 - d) d val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_pack_state #n1 #n2 d i = lseq uint8 (d * i) val frodo_pack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> i:size_nat{i < (n1 * n2) / 8} -> frodo_pack_state #n1 #n2 d i -> frodo_pack_state #n1 #n2 d (i + 1)
false
false
Spec.Frodo.Pack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_pack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> i:size_nat{i < (n1 * n2) / 8} -> frodo_pack_state #n1 #n2 d i -> frodo_pack_state #n1 #n2 d (i + 1)
[]
Spec.Frodo.Pack.frodo_pack_inner
{ "file_name": "specs/frodo/Spec.Frodo.Pack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d: Lib.IntTypes.size_nat{d * (n1 * n2 / 8) <= Lib.IntTypes.max_size_t /\ d <= 16} -> a: Spec.Matrix.matrix n1 n2 -> i: Lib.IntTypes.size_nat{i < n1 * n2 / 8} -> s: Spec.Frodo.Pack.frodo_pack_state d i -> Spec.Frodo.Pack.frodo_pack_state d (i + 1)
{ "end_col": 42, "end_line": 61, "start_col": 2, "start_line": 61 }
Prims.Tot
val frodo_unpack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> b:lbytes (d * ((n1 * n2) / 8)) -> i:size_nat{i < (n1 * n2) / 8} -> frodo_unpack_state #n1 #n2 i -> frodo_unpack_state #n1 #n2 (i + 1)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_unpack_inner #n1 #n2 d b i s = s @| frodo_unpack8 d (Seq.sub b (d * i) d)
val frodo_unpack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> b:lbytes (d * ((n1 * n2) / 8)) -> i:size_nat{i < (n1 * n2) / 8} -> frodo_unpack_state #n1 #n2 i -> frodo_unpack_state #n1 #n2 (i + 1) let frodo_unpack_inner #n1 #n2 d b i s =
false
null
false
s @| frodo_unpack8 d (Seq.sub b (d * i) d)
{ "checked_file": "Spec.Frodo.Pack.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Pack.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Mul.op_Star", "Lib.IntTypes.max_size_t", "Prims.op_Equality", "Prims.int", "Prims.op_Modulus", "Prims.op_Division", "Lib.ByteSequence.lbytes", "Prims.op_LessThan", "Spec.Frodo.Pack.frodo_unpack_state", "Lib.Sequence.op_At_Bar", "Lib.IntTypes.uint16", "Spec.Frodo.Pack.frodo_unpack8", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Prims.op_Addition" ]
[]
module Spec.Frodo.Pack open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix module Seq = Lib.Sequence module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar +FStar.Pervasives +FStar.UInt -Spec +Spec.Frodo +Spec.Frodo.Params +Spec.Matrix'" /// Pack val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d let frodo_pack8 d a = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let a0 = Seq.index a 0 &. maskd in let a1 = Seq.index a 1 &. maskd in let a2 = Seq.index a 2 &. maskd in let a3 = Seq.index a 3 &. maskd in let a4 = Seq.index a 4 &. maskd in let a5 = Seq.index a 5 &. maskd in let a6 = Seq.index a 6 &. maskd in let a7 = Seq.index a 7 &. maskd in let templong = to_u128 a0 <<. size (7 * d) |. to_u128 a1 <<. size (6 * d) |. to_u128 a2 <<. size (5 * d) |. to_u128 a3 <<. size (4 * d) |. to_u128 a4 <<. size (3 * d) |. to_u128 a5 <<. size (2 * d) |. to_u128 a6 <<. size (1 * d) |. to_u128 a7 <<. size (0 * d) in let v16 = uint_to_bytes_be templong in Seq.sub v16 (16 - d) d val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_pack_state #n1 #n2 d i = lseq uint8 (d * i) val frodo_pack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> i:size_nat{i < (n1 * n2) / 8} -> frodo_pack_state #n1 #n2 d i -> frodo_pack_state #n1 #n2 d (i + 1) let frodo_pack_inner #n1 #n2 d a i s = s @| frodo_pack8 d (Seq.sub a (8 * i) 8) val frodo_pack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> lbytes (d * ((n1 * n2) / 8)) let frodo_pack #n1 #n2 d a = Loops.repeat_gen ((n1 * n2) / 8) (frodo_pack_state #n1 #n2 d) (frodo_pack_inner #n1 #n2 d a) (Seq.create 0 (u8 0)) /// Unpack val frodo_unpack8: d:size_nat{d <= 16} -> b:lbytes d -> lseq uint16 8 let frodo_unpack8 d b = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let v16 = Seq.create 16 (u8 0) in let src = update_sub v16 (16 - d) d b in let templong: uint_t U128 SEC = uint_from_bytes_be src in let res = Seq.create 8 (u16 0) in let res = res.[0] <- to_u16 (templong >>. size (7 * d)) &. maskd in let res = res.[1] <- to_u16 (templong >>. size (6 * d)) &. maskd in let res = res.[2] <- to_u16 (templong >>. size (5 * d)) &. maskd in let res = res.[3] <- to_u16 (templong >>. size (4 * d)) &. maskd in let res = res.[4] <- to_u16 (templong >>. size (3 * d)) &. maskd in let res = res.[5] <- to_u16 (templong >>. size (2 * d)) &. maskd in let res = res.[6] <- to_u16 (templong >>. size (1 * d)) &. maskd in let res = res.[7] <- to_u16 (templong >>. size (0 * d)) &. maskd in res val frodo_unpack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_unpack_state #n1 #n2 i = lseq uint16 (8 * i) val frodo_unpack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> b:lbytes (d * ((n1 * n2) / 8)) -> i:size_nat{i < (n1 * n2) / 8} -> frodo_unpack_state #n1 #n2 i -> frodo_unpack_state #n1 #n2 (i + 1)
false
false
Spec.Frodo.Pack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_unpack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> b:lbytes (d * ((n1 * n2) / 8)) -> i:size_nat{i < (n1 * n2) / 8} -> frodo_unpack_state #n1 #n2 i -> frodo_unpack_state #n1 #n2 (i + 1)
[]
Spec.Frodo.Pack.frodo_unpack_inner
{ "file_name": "specs/frodo/Spec.Frodo.Pack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d: Lib.IntTypes.size_nat{d * (n1 * n2 / 8) <= Lib.IntTypes.max_size_t /\ d <= 16} -> b: Lib.ByteSequence.lbytes (d * (n1 * n2 / 8)) -> i: Lib.IntTypes.size_nat{i < n1 * n2 / 8} -> s: Spec.Frodo.Pack.frodo_unpack_state i -> Spec.Frodo.Pack.frodo_unpack_state (i + 1)
{ "end_col": 44, "end_line": 113, "start_col": 2, "start_line": 113 }
Prims.Tot
val frodo_unpack8: d:size_nat{d <= 16} -> b:lbytes d -> lseq uint16 8
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "Seq" }, { "abbrev": false, "full_module": "Spec.Matrix", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "Spec.Frodo", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let frodo_unpack8 d b = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let v16 = Seq.create 16 (u8 0) in let src = update_sub v16 (16 - d) d b in let templong: uint_t U128 SEC = uint_from_bytes_be src in let res = Seq.create 8 (u16 0) in let res = res.[0] <- to_u16 (templong >>. size (7 * d)) &. maskd in let res = res.[1] <- to_u16 (templong >>. size (6 * d)) &. maskd in let res = res.[2] <- to_u16 (templong >>. size (5 * d)) &. maskd in let res = res.[3] <- to_u16 (templong >>. size (4 * d)) &. maskd in let res = res.[4] <- to_u16 (templong >>. size (3 * d)) &. maskd in let res = res.[5] <- to_u16 (templong >>. size (2 * d)) &. maskd in let res = res.[6] <- to_u16 (templong >>. size (1 * d)) &. maskd in let res = res.[7] <- to_u16 (templong >>. size (0 * d)) &. maskd in res
val frodo_unpack8: d:size_nat{d <= 16} -> b:lbytes d -> lseq uint16 8 let frodo_unpack8 d b =
false
null
false
let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let v16 = Seq.create 16 (u8 0) in let src = update_sub v16 (16 - d) d b in let templong:uint_t U128 SEC = uint_from_bytes_be src in let res = Seq.create 8 (u16 0) in let res = res.[ 0 ] <- to_u16 (templong >>. size (7 * d)) &. maskd in let res = res.[ 1 ] <- to_u16 (templong >>. size (6 * d)) &. maskd in let res = res.[ 2 ] <- to_u16 (templong >>. size (5 * d)) &. maskd in let res = res.[ 3 ] <- to_u16 (templong >>. size (4 * d)) &. maskd in let res = res.[ 4 ] <- to_u16 (templong >>. size (3 * d)) &. maskd in let res = res.[ 5 ] <- to_u16 (templong >>. size (2 * d)) &. maskd in let res = res.[ 6 ] <- to_u16 (templong >>. size (1 * d)) &. maskd in let res = res.[ 7 ] <- to_u16 (templong >>. size (0 * d)) &. maskd in res
{ "checked_file": "Spec.Frodo.Pack.fst.checked", "dependencies": [ "Spec.Matrix.fst.checked", "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Spec.Frodo.Pack.fst" }
[ "total" ]
[ "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Lib.ByteSequence.lbytes", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U16", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Lib.IntTypes.logand", "Lib.IntTypes.cast", "Lib.IntTypes.U128", "Lib.IntTypes.shift_right", "Lib.IntTypes.mk_int", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.op_Multiply", "Lib.Sequence.index", "Prims.l_Forall", "Prims.nat", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_LessThan", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.uint16", "Lib.IntTypes.op_Amp_Dot", "Lib.IntTypes.to_u16", "Lib.IntTypes.op_Greater_Greater_Dot", "Lib.IntTypes.size", "FStar.Mul.op_Star", "FStar.Seq.Base.create", "Lib.Sequence.create", "Lib.IntTypes.u16", "Lib.ByteSequence.uint_from_bytes_be", "Lib.IntTypes.U8", "Lib.Sequence.sub", "Prims.op_Addition", "Lib.Sequence.update_sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.u8", "Lib.IntTypes.op_Subtraction_Dot", "Lib.IntTypes.op_Less_Less_Dot", "Lib.IntTypes.u32" ]
[]
module Spec.Frodo.Pack open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Spec.Matrix module Seq = Lib.Sequence module Loops = Lib.LoopCombinators #reset-options "--z3rlimit 100 --max_fuel 0 --max_ifuel 0 --using_facts_from '* -FStar +FStar.Pervasives +FStar.UInt -Spec +Spec.Frodo +Spec.Frodo.Params +Spec.Matrix'" /// Pack val frodo_pack8: d:size_nat{d <= 16} -> a:lseq uint16 8 -> lbytes d let frodo_pack8 d a = let maskd = to_u16 (u32 1 <<. size d) -. u16 1 in let a0 = Seq.index a 0 &. maskd in let a1 = Seq.index a 1 &. maskd in let a2 = Seq.index a 2 &. maskd in let a3 = Seq.index a 3 &. maskd in let a4 = Seq.index a 4 &. maskd in let a5 = Seq.index a 5 &. maskd in let a6 = Seq.index a 6 &. maskd in let a7 = Seq.index a 7 &. maskd in let templong = to_u128 a0 <<. size (7 * d) |. to_u128 a1 <<. size (6 * d) |. to_u128 a2 <<. size (5 * d) |. to_u128 a3 <<. size (4 * d) |. to_u128 a4 <<. size (3 * d) |. to_u128 a5 <<. size (2 * d) |. to_u128 a6 <<. size (1 * d) |. to_u128 a7 <<. size (0 * d) in let v16 = uint_to_bytes_be templong in Seq.sub v16 (16 - d) d val frodo_pack_state: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> i:size_nat{i <= (n1 * n2) / 8} -> Type0 let frodo_pack_state #n1 #n2 d i = lseq uint8 (d * i) val frodo_pack_inner: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> i:size_nat{i < (n1 * n2) / 8} -> frodo_pack_state #n1 #n2 d i -> frodo_pack_state #n1 #n2 d (i + 1) let frodo_pack_inner #n1 #n2 d a i s = s @| frodo_pack8 d (Seq.sub a (8 * i) 8) val frodo_pack: #n1:size_nat -> #n2:size_nat{n1 * n2 <= max_size_t /\ (n1 * n2) % 8 = 0} -> d:size_nat{d * ((n1 * n2) / 8) <= max_size_t /\ d <= 16} -> a:matrix n1 n2 -> lbytes (d * ((n1 * n2) / 8)) let frodo_pack #n1 #n2 d a = Loops.repeat_gen ((n1 * n2) / 8) (frodo_pack_state #n1 #n2 d) (frodo_pack_inner #n1 #n2 d a) (Seq.create 0 (u8 0)) /// Unpack val frodo_unpack8: d:size_nat{d <= 16} -> b:lbytes d
false
false
Spec.Frodo.Pack.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 100, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val frodo_unpack8: d:size_nat{d <= 16} -> b:lbytes d -> lseq uint16 8
[]
Spec.Frodo.Pack.frodo_unpack8
{ "file_name": "specs/frodo/Spec.Frodo.Pack.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
d: Lib.IntTypes.size_nat{d <= 16} -> b: Lib.ByteSequence.lbytes d -> Lib.Sequence.lseq Lib.IntTypes.uint16 8
{ "end_col": 5, "end_line": 95, "start_col": 23, "start_line": 81 }
Prims.Tot
val rounds:shuffle
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rounds : shuffle = repeat 10 double_round
val rounds:shuffle let rounds:shuffle =
false
null
false
repeat 10 double_round
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Lib.LoopCombinators.repeat", "Spec.Chacha20.state", "Spec.Chacha20.double_round" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *)
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 rounds:shuffle
[]
Spec.Chacha20.rounds
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Chacha20.shuffle
{ "end_col": 24, "end_line": 66, "start_col": 2, "start_line": 66 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let c2 = 0x79622d32ul
let c2 =
false
null
false
0x79622d32ul
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 c2 : FStar.UInt32.t
[]
Spec.Chacha20.c2
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.UInt32.t
{ "end_col": 21, "end_line": 105, "start_col": 9, "start_line": 105 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let c1 = 0x3320646eul
let c1 =
false
null
false
0x3320646eul
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 c1 : FStar.UInt32.t
[]
Spec.Chacha20.c1
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.UInt32.t
{ "end_col": 21, "end_line": 103, "start_col": 9, "start_line": 103 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_nonce = 12
let size_nonce =
false
null
false
12
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 size_nonce : Prims.int
[]
Spec.Chacha20.size_nonce
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 19, "end_line": 16, "start_col": 17, "start_line": 16 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let c0 = 0x61707865ul
let c0 =
false
null
false
0x61707865ul
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 c0 : FStar.UInt32.t
[]
Spec.Chacha20.c0
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.UInt32.t
{ "end_col": 21, "end_line": 101, "start_col": 9, "start_line": 101 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let keylen = 32
let keylen =
false
null
false
32
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 keylen : Prims.int
[]
Spec.Chacha20.keylen
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 15, "end_line": 19, "start_col": 13, "start_line": 19 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let noncelen = 12
let noncelen =
false
null
false
12
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *)
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 noncelen : Prims.int
[]
Spec.Chacha20.noncelen
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 17, "end_line": 21, "start_col": 15, "start_line": 21 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blocklen = 64
let blocklen =
false
null
false
64
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *)
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 blocklen : Prims.int
[]
Spec.Chacha20.blocklen
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 17, "end_line": 20, "start_col": 15, "start_line": 20 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let op_At f g = fun x -> g (f x)
let op_At f g =
false
null
false
fun x -> g (f x)
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state
false
false
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 op_At : f: (_: _ -> _) -> g: (_: _ -> _) -> x: _ -> _
[]
Spec.Chacha20.op_At
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: (_: _ -> _) -> g: (_: _ -> _) -> x: _ -> _
{ "end_col": 32, "end_line": 35, "start_col": 16, "start_line": 35 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_key = 32
let size_key =
false
null
false
32
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 size_key : Prims.int
[]
Spec.Chacha20.size_key
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 17, "end_line": 14, "start_col": 15, "start_line": 14 }
Prims.Tot
val chacha20_core (ctr: counter) (s0: state) : Tot state
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr
val chacha20_core (ctr: counter) (s0: state) : Tot state let chacha20_core (ctr: counter) (s0: state) : Tot state =
false
null
false
let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.counter", "Spec.Chacha20.state", "Spec.Chacha20.chacha20_add_counter", "Spec.Chacha20.sum_state", "Spec.Chacha20.rounds" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_core (ctr: counter) (s0: state) : Tot state
[]
Spec.Chacha20.chacha20_core
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ctr: Spec.Chacha20.counter -> s0: Spec.Chacha20.state -> Spec.Chacha20.state
{ "end_col": 29, "end_line": 98, "start_col": 57, "start_line": 94 }
Prims.Tot
val chacha20_encrypt_block (st0: state) (incr: counter) (b: block) : Tot block
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_encrypt_block (st0:state) (incr:counter) (b:block) : Tot block = let k = chacha20_core incr st0 in xor_block k b
val chacha20_encrypt_block (st0: state) (incr: counter) (b: block) : Tot block let chacha20_encrypt_block (st0: state) (incr: counter) (b: block) : Tot block =
false
null
false
let k = chacha20_core incr st0 in xor_block k b
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.state", "Spec.Chacha20.counter", "Spec.Chacha20.block", "Spec.Chacha20.xor_block", "Spec.Chacha20.chacha20_core" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st let chacha20_init (k:key) (n:nonce) (ctr0:counter) : Tot state = let st = create 16 (u32 0) in let st = setup k n ctr0 st in st let chacha20_key_block0 (k:key) (n:nonce) : Tot block = let st = chacha20_init k n 0 in let st = chacha20_core 0 st in uints_to_bytes_le st let chacha20_key_block (st:state) : Tot block = let st = chacha20_core 0 st in uints_to_bytes_le st let xor_block (k:state) (b:block) : block = let ib = uints_from_bytes_le b in let ob = map2 (^.) ib k in uints_to_bytes_le ob
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_encrypt_block (st0: state) (incr: counter) (b: block) : Tot block
[]
Spec.Chacha20.chacha20_encrypt_block
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st0: Spec.Chacha20.state -> incr: Spec.Chacha20.counter -> b: Spec.Chacha20.block -> Spec.Chacha20.block
{ "end_col": 15, "end_line": 143, "start_col": 77, "start_line": 141 }
Prims.Tot
val double_round:shuffle
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let double_round : shuffle = column_round @ diagonal_round
val double_round:shuffle let double_round:shuffle =
false
null
false
column_round @ diagonal_round
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.op_At", "Spec.Chacha20.state", "Spec.Chacha20.column_round", "Spec.Chacha20.diagonal_round" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 double_round:shuffle
[]
Spec.Chacha20.double_round
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Chacha20.shuffle
{ "end_col": 31, "end_line": 63, "start_col": 2, "start_line": 63 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size_block = 64
let size_block =
false
null
false
64
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 size_block : Prims.int
[]
Spec.Chacha20.size_block
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Prims.int
{ "end_col": 19, "end_line": 15, "start_col": 17, "start_line": 15 }
Prims.Tot
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let c3 = 0x6b206574ul
let c3 =
false
null
false
0x6b206574ul
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "FStar.UInt32.__uint_to_t" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 c3 : FStar.UInt32.t
[]
Spec.Chacha20.c3
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
FStar.UInt32.t
{ "end_col": 21, "end_line": 107, "start_col": 9, "start_line": 107 }
Prims.Tot
val chacha20_init (k: key) (n: nonce) (ctr0: counter) : Tot state
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_init (k:key) (n:nonce) (ctr0:counter) : Tot state = let st = create 16 (u32 0) in let st = setup k n ctr0 st in st
val chacha20_init (k: key) (n: nonce) (ctr0: counter) : Tot state let chacha20_init (k: key) (n: nonce) (ctr0: counter) : Tot state =
false
null
false
let st = create 16 (u32 0) in let st = setup k n ctr0 st in st
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.key", "Spec.Chacha20.nonce", "Spec.Chacha20.counter", "Spec.Chacha20.state", "Spec.Chacha20.setup", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.index", "Lib.Sequence.create", "Lib.IntTypes.uint32", "Lib.IntTypes.u32" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_init (k: key) (n: nonce) (ctr0: counter) : Tot state
[]
Spec.Chacha20.chacha20_init
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Chacha20.key -> n: Spec.Chacha20.nonce -> ctr0: Spec.Chacha20.counter -> Spec.Chacha20.state
{ "end_col": 4, "end_line": 125, "start_col": 64, "start_line": 122 }
Prims.Tot
val column_round:shuffle
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15
val column_round:shuffle let column_round:shuffle =
false
null
false
quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.op_At", "Spec.Chacha20.state", "Spec.Chacha20.quarter_round" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7)
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 column_round:shuffle
[]
Spec.Chacha20.column_round
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Chacha20.shuffle
{ "end_col": 25, "end_line": 54, "start_col": 2, "start_line": 51 }
Prims.Tot
val sum_state (s0 s1: state) : Tot state
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1
val sum_state (s0 s1: state) : Tot state let sum_state (s0 s1: state) : Tot state =
false
null
false
map2 ( +. ) s0 s1
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.state", "Lib.Sequence.map2", "Lib.IntTypes.uint32", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.U32", "Lib.IntTypes.SEC" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *)
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 sum_state (s0 s1: state) : Tot state
[]
Spec.Chacha20.sum_state
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s0: Spec.Chacha20.state -> s1: Spec.Chacha20.state -> Spec.Chacha20.state
{ "end_col": 17, "end_line": 69, "start_col": 2, "start_line": 69 }
Prims.Tot
val diagonal_round:shuffle
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14
val diagonal_round:shuffle let diagonal_round:shuffle =
false
null
false
quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.op_At", "Spec.Chacha20.state", "Spec.Chacha20.quarter_round" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 diagonal_round:shuffle
[]
Spec.Chacha20.diagonal_round
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Spec.Chacha20.shuffle
{ "end_col": 25, "end_line": 60, "start_col": 2, "start_line": 57 }
Prims.Tot
val chacha20_add_counter (s0: state) (ctr: counter) : Tot state
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr
val chacha20_add_counter (s0: state) (ctr: counter) : Tot state let chacha20_add_counter (s0: state) (ctr: counter) : Tot state =
false
null
false
s0.[ 12 ] <- s0.[ 12 ] +. u32 ctr
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.state", "Spec.Chacha20.counter", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.uint32", "Lib.IntTypes.op_Plus_Dot", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Lib.Sequence.op_String_Access", "Lib.IntTypes.u32" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_add_counter (s0: state) (ctr: counter) : Tot state
[]
Spec.Chacha20.chacha20_add_counter
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s0: Spec.Chacha20.state -> ctr: Spec.Chacha20.counter -> Spec.Chacha20.state
{ "end_col": 31, "end_line": 72, "start_col": 2, "start_line": 72 }
Prims.Tot
val chacha20_key_block (st: state) : Tot block
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_key_block (st:state) : Tot block = let st = chacha20_core 0 st in uints_to_bytes_le st
val chacha20_key_block (st: state) : Tot block let chacha20_key_block (st: state) : Tot block =
false
null
false
let st = chacha20_core 0 st in uints_to_bytes_le st
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.state", "Lib.ByteSequence.uints_to_bytes_le", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Spec.Chacha20.chacha20_core", "Spec.Chacha20.block" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st let chacha20_init (k:key) (n:nonce) (ctr0:counter) : Tot state = let st = create 16 (u32 0) in let st = setup k n ctr0 st in st let chacha20_key_block0 (k:key) (n:nonce) : Tot block = let st = chacha20_init k n 0 in let st = chacha20_core 0 st in uints_to_bytes_le st
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_key_block (st: state) : Tot block
[]
Spec.Chacha20.chacha20_key_block
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st: Spec.Chacha20.state -> Spec.Chacha20.block
{ "end_col": 22, "end_line": 134, "start_col": 47, "start_line": 132 }
Prims.Tot
val xor_block (k: state) (b: block) : block
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let xor_block (k:state) (b:block) : block = let ib = uints_from_bytes_le b in let ob = map2 (^.) ib k in uints_to_bytes_le ob
val xor_block (k: state) (b: block) : block let xor_block (k: state) (b: block) : block =
false
null
false
let ib = uints_from_bytes_le b in let ob = map2 ( ^. ) ib k in uints_to_bytes_le ob
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.state", "Spec.Chacha20.block", "Lib.ByteSequence.uints_to_bytes_le", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Prims.l_Forall", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "Prims.eq2", "Lib.Sequence.index", "Lib.IntTypes.logxor", "Lib.Sequence.map2", "Lib.IntTypes.uint_t", "Lib.IntTypes.uint32", "Lib.IntTypes.op_Hat_Dot", "Lib.ByteSequence.uints_from_bytes_le" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st let chacha20_init (k:key) (n:nonce) (ctr0:counter) : Tot state = let st = create 16 (u32 0) in let st = setup k n ctr0 st in st let chacha20_key_block0 (k:key) (n:nonce) : Tot block = let st = chacha20_init k n 0 in let st = chacha20_core 0 st in uints_to_bytes_le st let chacha20_key_block (st:state) : Tot block = let st = chacha20_core 0 st in uints_to_bytes_le st
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 xor_block (k: state) (b: block) : block
[]
Spec.Chacha20.xor_block
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Chacha20.state -> b: Spec.Chacha20.block -> Spec.Chacha20.block
{ "end_col": 22, "end_line": 139, "start_col": 44, "start_line": 136 }
Prims.Tot
val chacha20_encrypt_bytes: k: key -> n: nonce -> c: counter -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg}
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_encrypt_bytes key nonce ctr0 msg = let st0 = chacha20_init key nonce ctr0 in chacha20_update st0 msg
val chacha20_encrypt_bytes: k: key -> n: nonce -> c: counter -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_encrypt_bytes key nonce ctr0 msg =
false
null
false
let st0 = chacha20_init key nonce ctr0 in chacha20_update st0 msg
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.key", "Spec.Chacha20.nonce", "Spec.Chacha20.counter", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Chacha20.size_block", "Lib.IntTypes.max_size_t", "Spec.Chacha20.chacha20_update", "Spec.Chacha20.state", "Spec.Chacha20.chacha20_init", "Prims.eq2", "Prims.nat" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st let chacha20_init (k:key) (n:nonce) (ctr0:counter) : Tot state = let st = create 16 (u32 0) in let st = setup k n ctr0 st in st let chacha20_key_block0 (k:key) (n:nonce) : Tot block = let st = chacha20_init k n 0 in let st = chacha20_core 0 st in uints_to_bytes_le st let chacha20_key_block (st:state) : Tot block = let st = chacha20_core 0 st in uints_to_bytes_le st let xor_block (k:state) (b:block) : block = let ib = uints_from_bytes_le b in let ob = map2 (^.) ib k in uints_to_bytes_le ob let chacha20_encrypt_block (st0:state) (incr:counter) (b:block) : Tot block = let k = chacha20_core incr st0 in xor_block k b let chacha20_encrypt_last (st0: state) (incr: counter) (len: size_nat{len < size_block}) (b: lbytes len) : Tot (lbytes len) = let plain = create size_block (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 (length b) val chacha20_update: ctx: state -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_update ctx msg = let cipher = msg in map_blocks size_block cipher (chacha20_encrypt_block ctx) (chacha20_encrypt_last ctx) val chacha20_encrypt_bytes: k: key -> n: nonce -> c: counter -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg}
false
false
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_encrypt_bytes: k: key -> n: nonce -> c: counter -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg}
[]
Spec.Chacha20.chacha20_encrypt_bytes
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Chacha20.key -> n: Spec.Chacha20.nonce -> c: Spec.Chacha20.counter -> msg: Lib.ByteSequence.bytes {Lib.Sequence.length msg / Spec.Chacha20.size_block <= Lib.IntTypes.max_size_t} -> cipher: Lib.ByteSequence.bytes{Lib.Sequence.length cipher == Lib.Sequence.length msg}
{ "end_col": 25, "end_line": 179, "start_col": 47, "start_line": 177 }
Prims.Tot
val chacha20_decrypt_bytes: k: key -> n: nonce -> c: counter -> cipher: bytes{length cipher / size_block <= max_size_t} -> msg: bytes{length cipher == length msg}
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_decrypt_bytes key nonce ctr0 cipher = let st0 = chacha20_init key nonce ctr0 in chacha20_update st0 cipher
val chacha20_decrypt_bytes: k: key -> n: nonce -> c: counter -> cipher: bytes{length cipher / size_block <= max_size_t} -> msg: bytes{length cipher == length msg} let chacha20_decrypt_bytes key nonce ctr0 cipher =
false
null
false
let st0 = chacha20_init key nonce ctr0 in chacha20_update st0 cipher
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.key", "Spec.Chacha20.nonce", "Spec.Chacha20.counter", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Chacha20.size_block", "Lib.IntTypes.max_size_t", "Spec.Chacha20.chacha20_update", "Spec.Chacha20.state", "Spec.Chacha20.chacha20_init", "Prims.eq2", "Prims.nat" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st let chacha20_init (k:key) (n:nonce) (ctr0:counter) : Tot state = let st = create 16 (u32 0) in let st = setup k n ctr0 st in st let chacha20_key_block0 (k:key) (n:nonce) : Tot block = let st = chacha20_init k n 0 in let st = chacha20_core 0 st in uints_to_bytes_le st let chacha20_key_block (st:state) : Tot block = let st = chacha20_core 0 st in uints_to_bytes_le st let xor_block (k:state) (b:block) : block = let ib = uints_from_bytes_le b in let ob = map2 (^.) ib k in uints_to_bytes_le ob let chacha20_encrypt_block (st0:state) (incr:counter) (b:block) : Tot block = let k = chacha20_core incr st0 in xor_block k b let chacha20_encrypt_last (st0: state) (incr: counter) (len: size_nat{len < size_block}) (b: lbytes len) : Tot (lbytes len) = let plain = create size_block (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 (length b) val chacha20_update: ctx: state -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_update ctx msg = let cipher = msg in map_blocks size_block cipher (chacha20_encrypt_block ctx) (chacha20_encrypt_last ctx) val chacha20_encrypt_bytes: k: key -> n: nonce -> c: counter -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_encrypt_bytes key nonce ctr0 msg = let st0 = chacha20_init key nonce ctr0 in chacha20_update st0 msg val chacha20_decrypt_bytes: k: key -> n: nonce -> c: counter -> cipher: bytes{length cipher / size_block <= max_size_t} -> msg: bytes{length cipher == length msg}
false
false
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_decrypt_bytes: k: key -> n: nonce -> c: counter -> cipher: bytes{length cipher / size_block <= max_size_t} -> msg: bytes{length cipher == length msg}
[]
Spec.Chacha20.chacha20_decrypt_bytes
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Chacha20.key -> n: Spec.Chacha20.nonce -> c: Spec.Chacha20.counter -> cipher: Lib.ByteSequence.bytes {Lib.Sequence.length cipher / Spec.Chacha20.size_block <= Lib.IntTypes.max_size_t} -> msg: Lib.ByteSequence.bytes{Lib.Sequence.length cipher == Lib.Sequence.length msg}
{ "end_col": 28, "end_line": 191, "start_col": 50, "start_line": 189 }
Prims.Tot
val chacha20_encrypt_last (st0: state) (incr: counter) (len: size_nat{len < size_block}) (b: lbytes len) : Tot (lbytes len)
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_encrypt_last (st0: state) (incr: counter) (len: size_nat{len < size_block}) (b: lbytes len) : Tot (lbytes len) = let plain = create size_block (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 (length b)
val chacha20_encrypt_last (st0: state) (incr: counter) (len: size_nat{len < size_block}) (b: lbytes len) : Tot (lbytes len) let chacha20_encrypt_last (st0: state) (incr: counter) (len: size_nat{len < size_block}) (b: lbytes len) : Tot (lbytes len) =
false
null
false
let plain = create size_block (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 (length b)
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.state", "Spec.Chacha20.counter", "Lib.IntTypes.size_nat", "Prims.b2t", "Prims.op_LessThan", "Spec.Chacha20.size_block", "Lib.ByteSequence.lbytes", "Lib.Sequence.sub", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Lib.Sequence.length", "Spec.Chacha20.block", "Spec.Chacha20.chacha20_encrypt_block", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Prims.l_and", "Prims.eq2", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Sequence.update_sub", "FStar.Seq.Base.seq", "FStar.Seq.Base.create", "Lib.IntTypes.mk_int", "Prims.l_imp", "Lib.Sequence.create", "Lib.IntTypes.u8" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st let chacha20_init (k:key) (n:nonce) (ctr0:counter) : Tot state = let st = create 16 (u32 0) in let st = setup k n ctr0 st in st let chacha20_key_block0 (k:key) (n:nonce) : Tot block = let st = chacha20_init k n 0 in let st = chacha20_core 0 st in uints_to_bytes_le st let chacha20_key_block (st:state) : Tot block = let st = chacha20_core 0 st in uints_to_bytes_le st let xor_block (k:state) (b:block) : block = let ib = uints_from_bytes_le b in let ob = map2 (^.) ib k in uints_to_bytes_le ob let chacha20_encrypt_block (st0:state) (incr:counter) (b:block) : Tot block = let k = chacha20_core incr st0 in xor_block k b let chacha20_encrypt_last (st0: state) (incr: counter) (len: size_nat{len < size_block})
false
false
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_encrypt_last (st0: state) (incr: counter) (len: size_nat{len < size_block}) (b: lbytes len) : Tot (lbytes len)
[]
Spec.Chacha20.chacha20_encrypt_last
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
st0: Spec.Chacha20.state -> incr: Spec.Chacha20.counter -> len: Lib.IntTypes.size_nat{len < Spec.Chacha20.size_block} -> b: Lib.ByteSequence.lbytes len -> Lib.ByteSequence.lbytes len
{ "end_col": 25, "end_line": 155, "start_col": 20, "start_line": 150 }
Prims.Tot
val chacha20_constants:lseq size_t 4
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l
val chacha20_constants:lseq size_t 4 let chacha20_constants:lseq size_t 4 =
false
null
false
[@@ inline_let ]let l = [c0; c1; c2; c3] in assert_norm (List.Tot.length l == 4); createL l
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Lib.Sequence.createL", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "FStar.List.Tot.Base.length", "Prims.list", "Prims.Cons", "Spec.Chacha20.c0", "Spec.Chacha20.c1", "Spec.Chacha20.c2", "Spec.Chacha20.c3", "Prims.Nil" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul
false
false
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_constants:lseq size_t 4
[]
Spec.Chacha20.chacha20_constants
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U32 Lib.IntTypes.PUB) 4
{ "end_col": 11, "end_line": 113, "start_col": 2, "start_line": 110 }
Prims.Tot
val chacha20_update: ctx: state -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg}
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_update ctx msg = let cipher = msg in map_blocks size_block cipher (chacha20_encrypt_block ctx) (chacha20_encrypt_last ctx)
val chacha20_update: ctx: state -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg} let chacha20_update ctx msg =
false
null
false
let cipher = msg in map_blocks size_block cipher (chacha20_encrypt_block ctx) (chacha20_encrypt_last ctx)
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.state", "Lib.ByteSequence.bytes", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Division", "Lib.Sequence.length", "Lib.IntTypes.uint_t", "Lib.IntTypes.U8", "Lib.IntTypes.SEC", "Spec.Chacha20.size_block", "Lib.IntTypes.max_size_t", "Lib.Sequence.map_blocks", "Spec.Chacha20.chacha20_encrypt_block", "Spec.Chacha20.chacha20_encrypt_last", "Lib.Sequence.seq", "Lib.IntTypes.int_t", "Prims.op_Subtraction", "Prims.pow2", "Prims.eq2", "Prims.nat" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st let chacha20_init (k:key) (n:nonce) (ctr0:counter) : Tot state = let st = create 16 (u32 0) in let st = setup k n ctr0 st in st let chacha20_key_block0 (k:key) (n:nonce) : Tot block = let st = chacha20_init k n 0 in let st = chacha20_core 0 st in uints_to_bytes_le st let chacha20_key_block (st:state) : Tot block = let st = chacha20_core 0 st in uints_to_bytes_le st let xor_block (k:state) (b:block) : block = let ib = uints_from_bytes_le b in let ob = map2 (^.) ib k in uints_to_bytes_le ob let chacha20_encrypt_block (st0:state) (incr:counter) (b:block) : Tot block = let k = chacha20_core incr st0 in xor_block k b let chacha20_encrypt_last (st0: state) (incr: counter) (len: size_nat{len < size_block}) (b: lbytes len) : Tot (lbytes len) = let plain = create size_block (u8 0) in let plain = update_sub plain 0 len b in let cipher = chacha20_encrypt_block st0 incr plain in sub cipher 0 (length b) val chacha20_update: ctx: state -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg}
false
false
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_update: ctx: state -> msg: bytes{length msg / size_block <= max_size_t} -> cipher: bytes{length cipher == length msg}
[]
Spec.Chacha20.chacha20_update
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ctx: Spec.Chacha20.state -> msg: Lib.ByteSequence.bytes {Lib.Sequence.length msg / Spec.Chacha20.size_block <= Lib.IntTypes.max_size_t} -> cipher: Lib.ByteSequence.bytes{Lib.Sequence.length cipher == Lib.Sequence.length msg}
{ "end_col": 31, "end_line": 167, "start_col": 29, "start_line": 163 }
Prims.Tot
val chacha20_key_block0 (k: key) (n: nonce) : Tot block
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let chacha20_key_block0 (k:key) (n:nonce) : Tot block = let st = chacha20_init k n 0 in let st = chacha20_core 0 st in uints_to_bytes_le st
val chacha20_key_block0 (k: key) (n: nonce) : Tot block let chacha20_key_block0 (k: key) (n: nonce) : Tot block =
false
null
false
let st = chacha20_init k n 0 in let st = chacha20_core 0 st in uints_to_bytes_le st
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.key", "Spec.Chacha20.nonce", "Lib.ByteSequence.uints_to_bytes_le", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Spec.Chacha20.state", "Spec.Chacha20.chacha20_core", "Spec.Chacha20.chacha20_init", "Spec.Chacha20.block" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st let chacha20_init (k:key) (n:nonce) (ctr0:counter) : Tot state = let st = create 16 (u32 0) in let st = setup k n ctr0 st in st
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 chacha20_key_block0 (k: key) (n: nonce) : Tot block
[]
Spec.Chacha20.chacha20_key_block0
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Chacha20.key -> n: Spec.Chacha20.nonce -> Spec.Chacha20.block
{ "end_col": 22, "end_line": 130, "start_col": 55, "start_line": 127 }
Prims.Tot
val line (a b d: idx) (s: rotval U32) (m: state) : Tot state
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m
val line (a b d: idx) (s: rotval U32) (m: state) : Tot state let line (a b d: idx) (s: rotval U32) (m: state) : Tot state =
false
null
false
let m = m.[ a ] <- (m.[ a ] +. m.[ b ]) in let m = m.[ d ] <- ((m.[ d ] ^. m.[ a ]) <<<. s) in m
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.idx", "Lib.IntTypes.rotval", "Lib.IntTypes.U32", "Spec.Chacha20.state", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "FStar.Seq.Base.seq", "Lib.Sequence.to_seq", "FStar.Seq.Base.upd", "Lib.IntTypes.rotate_left", "Lib.IntTypes.logxor", "Lib.Sequence.index", "Prims.l_Forall", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_LessThan", "Prims.op_disEquality", "Prims.l_or", "FStar.Seq.Base.index", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.uint32", "Lib.IntTypes.op_Less_Less_Less_Dot", "Lib.IntTypes.op_Hat_Dot", "Lib.Sequence.op_String_Access", "Lib.IntTypes.add_mod", "Lib.IntTypes.op_Plus_Dot" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 line (a b d: idx) (s: rotval U32) (m: state) : Tot state
[]
Spec.Chacha20.line
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a: Spec.Chacha20.idx -> b: Spec.Chacha20.idx -> d: Spec.Chacha20.idx -> s: Lib.IntTypes.rotval Lib.IntTypes.U32 -> m: Spec.Chacha20.state -> Spec.Chacha20.state
{ "end_col": 49, "end_line": 42, "start_col": 71, "start_line": 40 }
Prims.Tot
val setup (k: key) (n: nonce) (ctr0: counter) (st: state) : Tot state
[ { "abbrev": false, "full_module": "Lib.LoopCombinators", "short_module": null }, { "abbrev": false, "full_module": "Lib.ByteSequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "Spec", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let setup (k:key) (n:nonce) (ctr0:counter) (st:state) : Tot state = let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[12] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st
val setup (k: key) (n: nonce) (ctr0: counter) (st: state) : Tot state let setup (k: key) (n: nonce) (ctr0: counter) (st: state) : Tot state =
false
null
false
let st = update_sub st 0 4 (map secret chacha20_constants) in let st = update_sub st 4 8 (uints_from_bytes_le #U32 #SEC #8 k) in let st = st.[ 12 ] <- u32 ctr0 in let st = update_sub st 13 3 (uints_from_bytes_le #U32 #SEC #3 n) in st
{ "checked_file": "Spec.Chacha20.fst.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.ByteSequence.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "Spec.Chacha20.fst" }
[ "total" ]
[ "Spec.Chacha20.key", "Spec.Chacha20.nonce", "Spec.Chacha20.counter", "Spec.Chacha20.state", "Lib.Sequence.lseq", "Lib.IntTypes.int_t", "Lib.IntTypes.U32", "Lib.IntTypes.SEC", "Prims.l_and", "Prims.eq2", "Lib.Sequence.sub", "Lib.ByteSequence.uints_from_bytes_le", "Prims.l_Forall", "Prims.nat", "Prims.l_or", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Prims.op_Addition", "FStar.Seq.Base.index", "Lib.Sequence.to_seq", "Lib.Sequence.index", "Lib.Sequence.update_sub", "Lib.IntTypes.uint32", "FStar.Seq.Base.seq", "FStar.Seq.Base.upd", "Lib.IntTypes.mk_int", "Prims.op_Subtraction", "Prims.pow2", "Prims.l_imp", "Prims.op_disEquality", "Lib.Sequence.op_String_Assignment", "Lib.IntTypes.u32", "Lib.Sequence.map", "Lib.IntTypes.PUB", "Lib.IntTypes.secret", "Spec.Chacha20.chacha20_constants" ]
[]
module Spec.Chacha20 open FStar.Mul open Lib.IntTypes open Lib.Sequence open Lib.ByteSequence open Lib.LoopCombinators #set-options "--max_fuel 0 --z3rlimit 100" /// Constants and Types let size_key = 32 let size_block = 64 let size_nonce = 12 (* TODO: Remove, left here to avoid breaking implementation *) let keylen = 32 (* in bytes *) let blocklen = 64 (* in bytes *) let noncelen = 12 (* in bytes *) type key = lbytes size_key type block = lbytes size_block type nonce = lbytes size_nonce type counter = size_nat type subblock = b:bytes{length b <= size_block} // Internally, blocks are represented as 16 x 4-byte integers type state = lseq uint32 16 type idx = n:size_nat{n < 16} type shuffle = state -> Tot state // Using @ as a functional substitute for ; let op_At f g = fun x -> g (f x) /// Specification let line (a:idx) (b:idx) (d:idx) (s:rotval U32) (m:state) : Tot state = let m = m.[a] <- (m.[a] +. m.[b]) in let m = m.[d] <- ((m.[d] ^. m.[a]) <<<. s) in m let quarter_round a b c d : Tot shuffle = line a b d (size 16) @ line c d b (size 12) @ line a b d (size 8) @ line c d b (size 7) let column_round : shuffle = quarter_round 0 4 8 12 @ quarter_round 1 5 9 13 @ quarter_round 2 6 10 14 @ quarter_round 3 7 11 15 let diagonal_round : shuffle = quarter_round 0 5 10 15 @ quarter_round 1 6 11 12 @ quarter_round 2 7 8 13 @ quarter_round 3 4 9 14 let double_round : shuffle = column_round @ diagonal_round (* 2 rounds *) let rounds : shuffle = repeat 10 double_round (* 20 rounds *) let sum_state (s0:state) (s1:state) : Tot state = map2 (+.) s0 s1 let chacha20_add_counter (s0:state) (ctr:counter) : Tot state = s0.[12] <- s0.[12] +. u32 ctr // protz 10:37 AM // question about chacha20 spec: why the double counter increment in chacha20_core? // https://github.com/project-everest/hacl-star/blob/_dev/specs/Spec.Chacha20.fst#L75 // is this in the spec? // karthik 11:28 AM // This is doing the same as: // // let chacha20_core (ctr:counter) (s0:state) : Tot state = // let s0 = chacha20_add_counter s0 ctr in // let k = rounds s0 in // sum_state k s0 // // but we rewrite in this way so that s0 remains constant // (in the code) // protz 11:32 AM // do sum_state and add_counter commute? // I feel like I'm missing some equational property of these sub-combinators // to understand why this is true // karthik 11:33 AM // yes, they do. let chacha20_core (ctr:counter) (s0:state) : Tot state = let k = chacha20_add_counter s0 ctr in let k = rounds k in let k = sum_state k s0 in chacha20_add_counter k ctr inline_for_extraction let c0 = 0x61707865ul inline_for_extraction let c1 = 0x3320646eul inline_for_extraction let c2 = 0x79622d32ul inline_for_extraction let c3 = 0x6b206574ul let chacha20_constants : lseq size_t 4 = [@ inline_let] let l = [c0;c1;c2;c3] in assert_norm(List.Tot.length l == 4); createL l
false
true
Spec.Chacha20.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_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 setup (k: key) (n: nonce) (ctr0: counter) (st: state) : Tot state
[]
Spec.Chacha20.setup
{ "file_name": "specs/Spec.Chacha20.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
k: Spec.Chacha20.key -> n: Spec.Chacha20.nonce -> ctr0: Spec.Chacha20.counter -> st: Spec.Chacha20.state -> Spec.Chacha20.state
{ "end_col": 4, "end_line": 120, "start_col": 67, "start_line": 115 }
Prims.Tot
val get_last_s (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) : lseq a (len % blocksize)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_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_last_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) : lseq a (len % blocksize) = let rem = len % blocksize in let b: lseq a rem = Seq.slice inp (len - rem) len in b
val get_last_s (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) : lseq a (len % blocksize) let get_last_s (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) : lseq a (len % blocksize) =
false
null
false
let rem = len % blocksize in let b:lseq a rem = Seq.slice inp (len - rem) len in b
{ "checked_file": "Lib.Sequence.Lemmas.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.Lemmas.fsti" }
[ "total" ]
[ "Prims.nat", "Lib.IntTypes.size_pos", "Lib.Sequence.seq", "Prims.eq2", "Lib.Sequence.length", "Lib.Sequence.lseq", "FStar.Seq.Base.slice", "Prims.op_Subtraction", "Prims.int", "Prims.op_Modulus" ]
[]
module Lib.Sequence.Lemmas open FStar.Mul open Lib.IntTypes open Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 \ --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence +Lib.Sequence.Lemmas'" let get_block_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (i:nat{i < len / blocksize * blocksize}) : lseq a blocksize = div_mul_lt blocksize i (len / blocksize); let j = i / blocksize in let b: lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in b let get_last_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) :
false
false
Lib.Sequence.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_last_s (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) : lseq a (len % blocksize)
[]
Lib.Sequence.Lemmas.get_last_s
{ "file_name": "lib/Lib.Sequence.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> inp: Lib.Sequence.seq a {Lib.Sequence.length inp == len} -> Lib.Sequence.lseq a (len % blocksize)
{ "end_col": 3, "end_line": 36, "start_col": 1, "start_line": 33 }
Prims.Tot
val repeat_gen_blocks_map_l (#a: Type0) (blocksize: size_pos) (hi: nat) (l: (i: nat{i <= hi} -> rem: nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i: nat{i <= hi}) (rem: nat{rem < blocksize}) (block_l: lseq a rem) (acc: map_blocks_a a blocksize hi i) : seq a
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repeat_gen_blocks_map_l (#a:Type0) (blocksize:size_pos) (hi:nat) (l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i:nat{i <= hi}) (rem:nat{rem < blocksize}) (block_l:lseq a rem) (acc:map_blocks_a a blocksize hi i) : seq a = if rem > 0 then Seq.append acc (l i rem block_l) else acc
val repeat_gen_blocks_map_l (#a: Type0) (blocksize: size_pos) (hi: nat) (l: (i: nat{i <= hi} -> rem: nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i: nat{i <= hi}) (rem: nat{rem < blocksize}) (block_l: lseq a rem) (acc: map_blocks_a a blocksize hi i) : seq a let repeat_gen_blocks_map_l (#a: Type0) (blocksize: size_pos) (hi: nat) (l: (i: nat{i <= hi} -> rem: nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i: nat{i <= hi}) (rem: nat{rem < blocksize}) (block_l: lseq a rem) (acc: map_blocks_a a blocksize hi i) : seq a =
false
null
false
if rem > 0 then Seq.append acc (l i rem block_l) else acc
{ "checked_file": "Lib.Sequence.Lemmas.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.Lemmas.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.Sequence.map_blocks_a", "Prims.op_GreaterThan", "FStar.Seq.Base.append", "Prims.bool", "Lib.Sequence.seq" ]
[]
module Lib.Sequence.Lemmas open FStar.Mul open Lib.IntTypes open Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 \ --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence +Lib.Sequence.Lemmas'" let get_block_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (i:nat{i < len / blocksize * blocksize}) : lseq a blocksize = div_mul_lt blocksize i (len / blocksize); let j = i / blocksize in let b: lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in b let get_last_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) : lseq a (len % blocksize) = let rem = len % blocksize in let b: lseq a rem = Seq.slice inp (len - rem) len in b val repeati_extensionality: #a:Type0 -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g i acc)) (ensures Loops.repeati n f acc0 == Loops.repeati n g acc0) val repeat_right_extensionality: n:nat -> lo:nat -> a_f:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> a_g:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> f:(i:nat{lo <= i /\ i < lo + n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo <= i /\ i < lo + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f lo -> Lemma (requires (forall (i:nat{lo <= i /\ i <= lo + n}). a_f i == a_g i) /\ (forall (i:nat{lo <= i /\ i < lo + n}) (acc:a_f i). f i acc == g i acc)) (ensures Loops.repeat_right lo (lo + n) a_f f acc0 == Loops.repeat_right lo (lo + n) a_g g acc0) // Loops.repeat_gen n a_f f acc0 == // Loops.repeat_right lo_g (lo_g + n) a_g g acc0) val repeat_gen_right_extensionality: n:nat -> lo_g:nat -> a_f:(i:nat{i <= n} -> Type) -> a_g:(i:nat{lo_g <= i /\ i <= lo_g + n} -> Type) -> f:(i:nat{i < n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f 0 -> Lemma (requires (forall (i:nat{i <= n}). a_f i == a_g (lo_g + i)) /\ (forall (i:nat{i < n}) (acc:a_f i). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n a_f f acc0 == Loops.repeat_right lo_g (lo_g + n) a_g g acc0) // Loops.repeati n a f acc0 == // Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0 val repeati_right_extensionality: #a:Type -> n:nat -> lo_g:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n (Loops.fixed_a a) f acc0 == Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0) /// A specialized version of the lemma above, for only shifting one computation, /// but specified using repeati instead val repeati_right_shift: #a:Type -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < 1 + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (i + 1) acc)) (ensures Loops.repeati n f (g 0 acc0) == Loops.repeati (n + 1) g acc0) /// /// `repeat_gen_blocks` is defined here to prove all the properties /// needed for `map_blocks` and `repeat_blocks` once /// let repeat_gen_blocks_f (#inp_t:Type0) (blocksize:size_pos) (mi:nat) (hi:nat) (n:nat{mi + n <= hi}) (inp:seq inp_t{length inp == n * blocksize}) (a:(i:nat{i <= hi} -> Type)) (f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i:nat{mi <= i /\ i < mi + n}) (acc:a i) : a (i + 1) = let i_b = i - mi in Math.Lemmas.lemma_mult_le_right blocksize (i_b + 1) n; let block = Seq.slice inp (i_b * blocksize) (i_b * blocksize + blocksize) in f i block acc //lo = 0 val repeat_gen_blocks_multi: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> a (mi + n) val lemma_repeat_gen_blocks_multi: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> Lemma (repeat_gen_blocks_multi #inp_t blocksize mi hi n inp a f acc0 == Loops.repeat_right mi (mi + n) a (repeat_gen_blocks_f blocksize mi hi n inp a f) acc0) val repeat_gen_blocks: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq inp_t{mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acci:a mi -> c val lemma_repeat_gen_blocks: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq inp_t{mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acc0:a mi -> Lemma (let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_div nb blocksize; Math.Lemmas.cancel_mul_mod nb blocksize; let acc = repeat_gen_blocks_multi #inp_t blocksize mi hi nb blocks a f acc0 in repeat_gen_blocks blocksize mi hi inp a f l acc0 == l (mi + nb) rem last acc) val repeat_gen_blocks_multi_extensionality_zero: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi_f:nat -> hi_g:nat -> n:nat{mi + n <= hi_f /\ n <= hi_g} -> inp:seq inp_t{length inp == n * blocksize} -> a_f:(i:nat{i <= hi_f} -> Type) -> a_g:(i:nat{i <= hi_g} -> Type) -> f:(i:nat{i < hi_f} -> lseq inp_t blocksize -> a_f i -> a_f (i + 1)) -> g:(i:nat{i < hi_g} -> lseq inp_t blocksize -> a_g i -> a_g (i + 1)) -> acc0:a_f mi -> Lemma (requires (forall (i:nat{i <= n}). a_f (mi + i) == a_g i) /\ (forall (i:nat{i < n}) (block:lseq inp_t blocksize) (acc:a_f (mi + i)). f (mi + i) block acc == g i block acc)) (ensures repeat_gen_blocks_multi blocksize mi hi_f n inp a_f f acc0 == repeat_gen_blocks_multi blocksize 0 hi_g n inp a_g g acc0) val repeat_gen_blocks_extensionality_zero: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi_f:nat -> hi_g:nat -> n:nat{mi + n <= hi_f /\ n <= hi_g} -> inp:seq inp_t{n == length inp / blocksize} -> a_f:(i:nat{i <= hi_f} -> Type) -> a_g:(i:nat{i <= hi_g} -> Type) -> f:(i:nat{i < hi_f} -> lseq inp_t blocksize -> a_f i -> a_f (i + 1)) -> l_f:(i:nat{i <= hi_f} -> len:nat{len < blocksize} -> lseq inp_t len -> a_f i -> c) -> g:(i:nat{i < hi_g} -> lseq inp_t blocksize -> a_g i -> a_g (i + 1)) -> l_g:(i:nat{i <= hi_g} -> len:nat{len < blocksize} -> lseq inp_t len -> a_g i -> c) -> acc0:a_f mi -> Lemma (requires (forall (i:nat{i <= n}). a_f (mi + i) == a_g i) /\ (forall (i:nat{i < n}) (block:lseq inp_t blocksize) (acc:a_f (mi + i)). f (mi + i) block acc == g i block acc) /\ (forall (i:nat{i <= n}) (len:nat{len < blocksize}) (block:lseq inp_t len) (acc:a_f (mi + i)). l_f (mi + i) len block acc == l_g i len block acc)) (ensures repeat_gen_blocks blocksize mi hi_f inp a_f f l_f acc0 == repeat_gen_blocks blocksize 0 hi_g inp a_g g l_g acc0) val len0_div_bs: blocksize:pos -> len:nat -> len0:nat -> Lemma (requires len0 <= len /\ len0 % blocksize == 0) (ensures len0 / blocksize + (len - len0) / blocksize == len / blocksize) val split_len_lemma0: blocksize:pos -> n:nat -> len0:nat -> Lemma (requires len0 <= n * blocksize /\ len0 % blocksize = 0) (ensures (let len = n * blocksize in let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in len % blocksize = 0 /\ len1 % blocksize = 0 /\ n0 + n1 = n /\ n0 * blocksize = len0 /\ n1 * blocksize = len1)) val split_len_lemma: blocksize:pos -> len:nat -> len0:nat -> Lemma (requires len0 <= len /\ len0 % blocksize = 0) (ensures (let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in let n = len / blocksize in len % blocksize = len1 % blocksize /\ n0 * blocksize = len0 /\ n0 + n1 = n)) val repeat_gen_blocks_multi_split: #inp_t:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize == 0} -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{len0 <= length inp /\ length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> Lemma (let len = length inp in let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in split_len_lemma0 blocksize n len0; let t0 = Seq.slice inp 0 len0 in let t1 = Seq.slice inp len0 len in let acc : a (mi + n0) = repeat_gen_blocks_multi blocksize mi hi n0 t0 a f acc0 in repeat_gen_blocks_multi blocksize mi hi n inp a f acc0 == repeat_gen_blocks_multi blocksize (mi + n0) hi n1 t1 a f acc) val repeat_gen_blocks_split: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize == 0} -> hi:nat -> mi:nat{mi <= hi} -> inp:seq inp_t{len0 <= length inp /\ mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acc0:a mi -> Lemma (let len = length inp in let n = len / blocksize in let n0 = len0 / blocksize in split_len_lemma blocksize len len0; let t0 = Seq.slice inp 0 len0 in let t1 = Seq.slice inp len0 len in let acc : a (mi + n0) = repeat_gen_blocks_multi blocksize mi hi n0 t0 a f acc0 in repeat_gen_blocks blocksize mi hi inp a f l acc0 == repeat_gen_blocks blocksize (mi + n0) hi t1 a f l acc) /// /// Properties related to the repeat_blocks combinator /// val repeat_blocks_extensionality: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f1:(lseq a blocksize -> b -> b) -> f2:(lseq a blocksize -> b -> b) -> l1:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> l2:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (requires (forall (block:lseq a blocksize) (acc:b). f1 block acc == f2 block acc) /\ (forall (rem:nat{rem < blocksize}) (last:lseq a rem) (acc:b). l1 rem last acc == l2 rem last acc)) (ensures repeat_blocks blocksize inp f1 l1 acc0 == repeat_blocks blocksize inp f2 l2 acc0) val lemma_repeat_blocks_via_multi: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_mod nb blocksize; let acc = repeat_blocks_multi blocksize blocks f acc0 in repeat_blocks #a #b blocksize inp f l acc0 == l rem last acc) val repeat_blocks_multi_is_repeat_gen_blocks_multi: #a:Type0 -> #b:Type0 -> hi:nat -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0 /\ length inp / blocksize <= hi} -> f:(lseq a blocksize -> b -> b) -> acc0:b -> Lemma (let n = length inp / blocksize in Math.Lemmas.div_exact_r (length inp) blocksize; repeat_blocks_multi #a #b blocksize inp f acc0 == repeat_gen_blocks_multi #a blocksize 0 hi n inp (Loops.fixed_a b) (Loops.fixed_i f) acc0) val repeat_blocks_is_repeat_gen_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> hi:nat -> blocksize:size_pos -> inp:seq a{length inp / blocksize <= hi} -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (repeat_blocks #a #b #c blocksize inp f l acc0 == repeat_gen_blocks #a #c blocksize 0 hi inp (Loops.fixed_a b) (Loops.fixed_i f) (Loops.fixed_i l) acc0) val repeat_blocks_multi_split: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize = 0} -> inp:seq a{len0 <= length inp /\ length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> acc0:b -> Lemma (let len = length inp in Math.Lemmas.lemma_div_exact len blocksize; split_len_lemma0 blocksize (len / blocksize) len0; Math.Lemmas.swap_mul blocksize (len / blocksize); repeat_blocks_multi blocksize inp f acc0 == repeat_blocks_multi blocksize (Seq.slice inp len0 len) f (repeat_blocks_multi blocksize (Seq.slice inp 0 len0) f acc0)) val repeat_blocks_split: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize = 0} -> inp:seq a{len0 <= length inp} -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (let len = length inp in split_len_lemma blocksize len len0; repeat_blocks blocksize inp f l acc0 == repeat_blocks blocksize (Seq.slice inp len0 len) f l (repeat_blocks_multi blocksize (Seq.slice inp 0 len0) f acc0)) /// val repeat_blocks_multi_extensionality: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> g:(lseq a blocksize -> b -> b) -> init:b -> Lemma (requires (forall (block:lseq a blocksize) (acc:b). f block acc == g block acc)) (ensures repeat_blocks_multi blocksize inp f init == repeat_blocks_multi blocksize inp g init) /// Properties related to the map_blocks combinator /// val map_blocks_multi_extensionality: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> g:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Lemma (requires (forall (i:nat{i < max}) (b_v:lseq a blocksize). f i b_v == g i b_v)) (ensures map_blocks_multi blocksize max n inp f == map_blocks_multi blocksize max n inp g) val map_blocks_extensionality: #a:Type0 -> blocksize:size_pos -> inp:seq a -> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> l_f:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> g:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> l_g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> Lemma (requires (let n = length inp / blocksize in (forall (i:nat{i < n}) (b_v:lseq a blocksize). f i b_v == g i b_v) /\ (forall (rem:nat{rem < blocksize}) (b_v:lseq a rem). l_f n rem b_v == l_g n rem b_v))) (ensures map_blocks blocksize inp f l_f == map_blocks blocksize inp g l_g) /// /// New definition of `map_blocks` that takes extra parameter `acc`. /// When `acc` = Seq.empty, map_blocks == map_blocks_acc /// let repeat_gen_blocks_map_f (#a:Type0) (blocksize:size_pos) (hi:nat) (f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < hi}) (block:lseq a blocksize) (acc:map_blocks_a a blocksize hi i) : map_blocks_a a blocksize hi (i + 1) = Seq.append acc (f i block) let repeat_gen_blocks_map_l (#a:Type0) (blocksize:size_pos) (hi:nat) (l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i:nat{i <= hi}) (rem:nat{rem < blocksize}) (block_l:lseq a rem) (acc:map_blocks_a a blocksize hi i) : seq a
false
false
Lib.Sequence.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeat_gen_blocks_map_l (#a: Type0) (blocksize: size_pos) (hi: nat) (l: (i: nat{i <= hi} -> rem: nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i: nat{i <= hi}) (rem: nat{rem < blocksize}) (block_l: lseq a rem) (acc: map_blocks_a a blocksize hi i) : seq a
[]
Lib.Sequence.Lemmas.repeat_gen_blocks_map_l
{ "file_name": "lib/Lib.Sequence.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> hi: Prims.nat -> l: (i: Prims.nat{i <= hi} -> rem: Prims.nat{rem < blocksize} -> _: Lib.Sequence.lseq a rem -> Lib.Sequence.lseq a rem) -> i: Prims.nat{i <= hi} -> rem: Prims.nat{rem < blocksize} -> block_l: Lib.Sequence.lseq a rem -> acc: Lib.Sequence.map_blocks_a a blocksize hi i -> Lib.Sequence.seq a
{ "end_col": 60, "end_line": 523, "start_col": 3, "start_line": 523 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let f_shift (#a:Type0) (blocksize:size_pos) (mi:nat) (hi:nat) (n:nat{mi + n <= hi}) (f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < n}) = f (mi + i)
let f_shift (#a: Type0) (blocksize: size_pos) (mi hi: nat) (n: nat{mi + n <= hi}) (f: (i: nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i: nat{i < n}) =
false
null
false
f (mi + i)
{ "checked_file": "Lib.Sequence.Lemmas.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.Lemmas.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Prims.op_LessThan", "Lib.Sequence.lseq" ]
[]
module Lib.Sequence.Lemmas open FStar.Mul open Lib.IntTypes open Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 \ --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence +Lib.Sequence.Lemmas'" let get_block_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (i:nat{i < len / blocksize * blocksize}) : lseq a blocksize = div_mul_lt blocksize i (len / blocksize); let j = i / blocksize in let b: lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in b let get_last_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) : lseq a (len % blocksize) = let rem = len % blocksize in let b: lseq a rem = Seq.slice inp (len - rem) len in b val repeati_extensionality: #a:Type0 -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g i acc)) (ensures Loops.repeati n f acc0 == Loops.repeati n g acc0) val repeat_right_extensionality: n:nat -> lo:nat -> a_f:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> a_g:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> f:(i:nat{lo <= i /\ i < lo + n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo <= i /\ i < lo + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f lo -> Lemma (requires (forall (i:nat{lo <= i /\ i <= lo + n}). a_f i == a_g i) /\ (forall (i:nat{lo <= i /\ i < lo + n}) (acc:a_f i). f i acc == g i acc)) (ensures Loops.repeat_right lo (lo + n) a_f f acc0 == Loops.repeat_right lo (lo + n) a_g g acc0) // Loops.repeat_gen n a_f f acc0 == // Loops.repeat_right lo_g (lo_g + n) a_g g acc0) val repeat_gen_right_extensionality: n:nat -> lo_g:nat -> a_f:(i:nat{i <= n} -> Type) -> a_g:(i:nat{lo_g <= i /\ i <= lo_g + n} -> Type) -> f:(i:nat{i < n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f 0 -> Lemma (requires (forall (i:nat{i <= n}). a_f i == a_g (lo_g + i)) /\ (forall (i:nat{i < n}) (acc:a_f i). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n a_f f acc0 == Loops.repeat_right lo_g (lo_g + n) a_g g acc0) // Loops.repeati n a f acc0 == // Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0 val repeati_right_extensionality: #a:Type -> n:nat -> lo_g:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n (Loops.fixed_a a) f acc0 == Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0) /// A specialized version of the lemma above, for only shifting one computation, /// but specified using repeati instead val repeati_right_shift: #a:Type -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < 1 + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (i + 1) acc)) (ensures Loops.repeati n f (g 0 acc0) == Loops.repeati (n + 1) g acc0) /// /// `repeat_gen_blocks` is defined here to prove all the properties /// needed for `map_blocks` and `repeat_blocks` once /// let repeat_gen_blocks_f (#inp_t:Type0) (blocksize:size_pos) (mi:nat) (hi:nat) (n:nat{mi + n <= hi}) (inp:seq inp_t{length inp == n * blocksize}) (a:(i:nat{i <= hi} -> Type)) (f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i:nat{mi <= i /\ i < mi + n}) (acc:a i) : a (i + 1) = let i_b = i - mi in Math.Lemmas.lemma_mult_le_right blocksize (i_b + 1) n; let block = Seq.slice inp (i_b * blocksize) (i_b * blocksize + blocksize) in f i block acc //lo = 0 val repeat_gen_blocks_multi: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> a (mi + n) val lemma_repeat_gen_blocks_multi: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> Lemma (repeat_gen_blocks_multi #inp_t blocksize mi hi n inp a f acc0 == Loops.repeat_right mi (mi + n) a (repeat_gen_blocks_f blocksize mi hi n inp a f) acc0) val repeat_gen_blocks: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq inp_t{mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acci:a mi -> c val lemma_repeat_gen_blocks: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq inp_t{mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acc0:a mi -> Lemma (let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_div nb blocksize; Math.Lemmas.cancel_mul_mod nb blocksize; let acc = repeat_gen_blocks_multi #inp_t blocksize mi hi nb blocks a f acc0 in repeat_gen_blocks blocksize mi hi inp a f l acc0 == l (mi + nb) rem last acc) val repeat_gen_blocks_multi_extensionality_zero: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi_f:nat -> hi_g:nat -> n:nat{mi + n <= hi_f /\ n <= hi_g} -> inp:seq inp_t{length inp == n * blocksize} -> a_f:(i:nat{i <= hi_f} -> Type) -> a_g:(i:nat{i <= hi_g} -> Type) -> f:(i:nat{i < hi_f} -> lseq inp_t blocksize -> a_f i -> a_f (i + 1)) -> g:(i:nat{i < hi_g} -> lseq inp_t blocksize -> a_g i -> a_g (i + 1)) -> acc0:a_f mi -> Lemma (requires (forall (i:nat{i <= n}). a_f (mi + i) == a_g i) /\ (forall (i:nat{i < n}) (block:lseq inp_t blocksize) (acc:a_f (mi + i)). f (mi + i) block acc == g i block acc)) (ensures repeat_gen_blocks_multi blocksize mi hi_f n inp a_f f acc0 == repeat_gen_blocks_multi blocksize 0 hi_g n inp a_g g acc0) val repeat_gen_blocks_extensionality_zero: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi_f:nat -> hi_g:nat -> n:nat{mi + n <= hi_f /\ n <= hi_g} -> inp:seq inp_t{n == length inp / blocksize} -> a_f:(i:nat{i <= hi_f} -> Type) -> a_g:(i:nat{i <= hi_g} -> Type) -> f:(i:nat{i < hi_f} -> lseq inp_t blocksize -> a_f i -> a_f (i + 1)) -> l_f:(i:nat{i <= hi_f} -> len:nat{len < blocksize} -> lseq inp_t len -> a_f i -> c) -> g:(i:nat{i < hi_g} -> lseq inp_t blocksize -> a_g i -> a_g (i + 1)) -> l_g:(i:nat{i <= hi_g} -> len:nat{len < blocksize} -> lseq inp_t len -> a_g i -> c) -> acc0:a_f mi -> Lemma (requires (forall (i:nat{i <= n}). a_f (mi + i) == a_g i) /\ (forall (i:nat{i < n}) (block:lseq inp_t blocksize) (acc:a_f (mi + i)). f (mi + i) block acc == g i block acc) /\ (forall (i:nat{i <= n}) (len:nat{len < blocksize}) (block:lseq inp_t len) (acc:a_f (mi + i)). l_f (mi + i) len block acc == l_g i len block acc)) (ensures repeat_gen_blocks blocksize mi hi_f inp a_f f l_f acc0 == repeat_gen_blocks blocksize 0 hi_g inp a_g g l_g acc0) val len0_div_bs: blocksize:pos -> len:nat -> len0:nat -> Lemma (requires len0 <= len /\ len0 % blocksize == 0) (ensures len0 / blocksize + (len - len0) / blocksize == len / blocksize) val split_len_lemma0: blocksize:pos -> n:nat -> len0:nat -> Lemma (requires len0 <= n * blocksize /\ len0 % blocksize = 0) (ensures (let len = n * blocksize in let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in len % blocksize = 0 /\ len1 % blocksize = 0 /\ n0 + n1 = n /\ n0 * blocksize = len0 /\ n1 * blocksize = len1)) val split_len_lemma: blocksize:pos -> len:nat -> len0:nat -> Lemma (requires len0 <= len /\ len0 % blocksize = 0) (ensures (let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in let n = len / blocksize in len % blocksize = len1 % blocksize /\ n0 * blocksize = len0 /\ n0 + n1 = n)) val repeat_gen_blocks_multi_split: #inp_t:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize == 0} -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{len0 <= length inp /\ length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> Lemma (let len = length inp in let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in split_len_lemma0 blocksize n len0; let t0 = Seq.slice inp 0 len0 in let t1 = Seq.slice inp len0 len in let acc : a (mi + n0) = repeat_gen_blocks_multi blocksize mi hi n0 t0 a f acc0 in repeat_gen_blocks_multi blocksize mi hi n inp a f acc0 == repeat_gen_blocks_multi blocksize (mi + n0) hi n1 t1 a f acc) val repeat_gen_blocks_split: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize == 0} -> hi:nat -> mi:nat{mi <= hi} -> inp:seq inp_t{len0 <= length inp /\ mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acc0:a mi -> Lemma (let len = length inp in let n = len / blocksize in let n0 = len0 / blocksize in split_len_lemma blocksize len len0; let t0 = Seq.slice inp 0 len0 in let t1 = Seq.slice inp len0 len in let acc : a (mi + n0) = repeat_gen_blocks_multi blocksize mi hi n0 t0 a f acc0 in repeat_gen_blocks blocksize mi hi inp a f l acc0 == repeat_gen_blocks blocksize (mi + n0) hi t1 a f l acc) /// /// Properties related to the repeat_blocks combinator /// val repeat_blocks_extensionality: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f1:(lseq a blocksize -> b -> b) -> f2:(lseq a blocksize -> b -> b) -> l1:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> l2:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (requires (forall (block:lseq a blocksize) (acc:b). f1 block acc == f2 block acc) /\ (forall (rem:nat{rem < blocksize}) (last:lseq a rem) (acc:b). l1 rem last acc == l2 rem last acc)) (ensures repeat_blocks blocksize inp f1 l1 acc0 == repeat_blocks blocksize inp f2 l2 acc0) val lemma_repeat_blocks_via_multi: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_mod nb blocksize; let acc = repeat_blocks_multi blocksize blocks f acc0 in repeat_blocks #a #b blocksize inp f l acc0 == l rem last acc) val repeat_blocks_multi_is_repeat_gen_blocks_multi: #a:Type0 -> #b:Type0 -> hi:nat -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0 /\ length inp / blocksize <= hi} -> f:(lseq a blocksize -> b -> b) -> acc0:b -> Lemma (let n = length inp / blocksize in Math.Lemmas.div_exact_r (length inp) blocksize; repeat_blocks_multi #a #b blocksize inp f acc0 == repeat_gen_blocks_multi #a blocksize 0 hi n inp (Loops.fixed_a b) (Loops.fixed_i f) acc0) val repeat_blocks_is_repeat_gen_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> hi:nat -> blocksize:size_pos -> inp:seq a{length inp / blocksize <= hi} -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (repeat_blocks #a #b #c blocksize inp f l acc0 == repeat_gen_blocks #a #c blocksize 0 hi inp (Loops.fixed_a b) (Loops.fixed_i f) (Loops.fixed_i l) acc0) val repeat_blocks_multi_split: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize = 0} -> inp:seq a{len0 <= length inp /\ length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> acc0:b -> Lemma (let len = length inp in Math.Lemmas.lemma_div_exact len blocksize; split_len_lemma0 blocksize (len / blocksize) len0; Math.Lemmas.swap_mul blocksize (len / blocksize); repeat_blocks_multi blocksize inp f acc0 == repeat_blocks_multi blocksize (Seq.slice inp len0 len) f (repeat_blocks_multi blocksize (Seq.slice inp 0 len0) f acc0)) val repeat_blocks_split: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize = 0} -> inp:seq a{len0 <= length inp} -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (let len = length inp in split_len_lemma blocksize len len0; repeat_blocks blocksize inp f l acc0 == repeat_blocks blocksize (Seq.slice inp len0 len) f l (repeat_blocks_multi blocksize (Seq.slice inp 0 len0) f acc0)) /// val repeat_blocks_multi_extensionality: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> g:(lseq a blocksize -> b -> b) -> init:b -> Lemma (requires (forall (block:lseq a blocksize) (acc:b). f block acc == g block acc)) (ensures repeat_blocks_multi blocksize inp f init == repeat_blocks_multi blocksize inp g init) /// Properties related to the map_blocks combinator /// val map_blocks_multi_extensionality: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> g:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Lemma (requires (forall (i:nat{i < max}) (b_v:lseq a blocksize). f i b_v == g i b_v)) (ensures map_blocks_multi blocksize max n inp f == map_blocks_multi blocksize max n inp g) val map_blocks_extensionality: #a:Type0 -> blocksize:size_pos -> inp:seq a -> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> l_f:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> g:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> l_g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> Lemma (requires (let n = length inp / blocksize in (forall (i:nat{i < n}) (b_v:lseq a blocksize). f i b_v == g i b_v) /\ (forall (rem:nat{rem < blocksize}) (b_v:lseq a rem). l_f n rem b_v == l_g n rem b_v))) (ensures map_blocks blocksize inp f l_f == map_blocks blocksize inp g l_g) /// /// New definition of `map_blocks` that takes extra parameter `acc`. /// When `acc` = Seq.empty, map_blocks == map_blocks_acc /// let repeat_gen_blocks_map_f (#a:Type0) (blocksize:size_pos) (hi:nat) (f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < hi}) (block:lseq a blocksize) (acc:map_blocks_a a blocksize hi i) : map_blocks_a a blocksize hi (i + 1) = Seq.append acc (f i block) let repeat_gen_blocks_map_l (#a:Type0) (blocksize:size_pos) (hi:nat) (l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i:nat{i <= hi}) (rem:nat{rem < blocksize}) (block_l:lseq a rem) (acc:map_blocks_a a blocksize hi i) : seq a = if rem > 0 then Seq.append acc (l i rem block_l) else acc val repeat_gen_blocks_map_l_length: #a:Type0 -> blocksize:size_pos -> hi:nat -> l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem) -> i:nat{i <= hi} -> rem:nat{rem < blocksize} -> block_l:lseq a rem -> acc:map_blocks_a a blocksize hi i -> Lemma (length (repeat_gen_blocks_map_l blocksize hi l i rem block_l acc) == i * blocksize + rem) val map_blocks_multi_acc: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq a{length inp == n * blocksize} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> acc0:map_blocks_a a blocksize hi mi -> out:seq a {length out == length acc0 + length inp} val map_blocks_acc: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq a{mi + length inp / blocksize <= hi} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem) -> acc0:map_blocks_a a blocksize hi mi -> seq a val map_blocks_acc_length: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq a{mi + length inp / blocksize <= hi} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem) -> acc0:map_blocks_a a blocksize hi mi -> Lemma (length (map_blocks_acc blocksize mi hi inp f l acc0) == length acc0 + length inp) [SMTPat (map_blocks_acc blocksize mi hi inp f l acc0)] val map_blocks_multi_acc_is_repeat_gen_blocks_multi: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq a{length inp == n * blocksize} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> acc0:map_blocks_a a blocksize hi mi -> Lemma (map_blocks_multi_acc #a blocksize mi hi n inp f acc0 == repeat_gen_blocks_multi #a blocksize mi hi n inp (map_blocks_a a blocksize hi) (repeat_gen_blocks_map_f blocksize hi f) acc0) val map_blocks_acc_is_repeat_gen_blocks: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq a{mi + length inp / blocksize <= hi} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem) -> acc0:map_blocks_a a blocksize hi mi -> Lemma (map_blocks_acc #a blocksize mi hi inp f l acc0 == repeat_gen_blocks #a blocksize mi hi inp (map_blocks_a a blocksize hi) (repeat_gen_blocks_map_f blocksize hi f) (repeat_gen_blocks_map_l blocksize hi l) acc0)
false
false
Lib.Sequence.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val f_shift : blocksize: Lib.IntTypes.size_pos -> mi: Prims.nat -> hi: Prims.nat -> n: Prims.nat{mi + n <= hi} -> f: (i: Prims.nat{i < hi} -> _: Lib.Sequence.lseq a blocksize -> Lib.Sequence.lseq a blocksize) -> i: Prims.nat{i < n} -> _: Lib.Sequence.lseq a blocksize -> Lib.Sequence.lseq a blocksize
[]
Lib.Sequence.Lemmas.f_shift
{ "file_name": "lib/Lib.Sequence.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> mi: Prims.nat -> hi: Prims.nat -> n: Prims.nat{mi + n <= hi} -> f: (i: Prims.nat{i < hi} -> _: Lib.Sequence.lseq a blocksize -> Lib.Sequence.lseq a blocksize) -> i: Prims.nat{i < n} -> _: Lib.Sequence.lseq a blocksize -> Lib.Sequence.lseq a blocksize
{ "end_col": 89, "end_line": 609, "start_col": 79, "start_line": 609 }
Prims.Tot
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let l_shift (#a:Type0) (blocksize:size_pos) (mi:nat) (hi:nat) (n:nat{mi + n <= hi}) (l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i:nat{i <= n}) = l (mi + i)
let l_shift (#a: Type0) (blocksize: size_pos) (mi hi: nat) (n: nat{mi + n <= hi}) (l: (i: nat{i <= hi} -> rem: nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i: nat{i <= n}) =
false
null
false
l (mi + i)
{ "checked_file": "Lib.Sequence.Lemmas.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.Lemmas.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Prims.op_LessThan", "Lib.Sequence.lseq" ]
[]
module Lib.Sequence.Lemmas open FStar.Mul open Lib.IntTypes open Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 \ --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence +Lib.Sequence.Lemmas'" let get_block_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (i:nat{i < len / blocksize * blocksize}) : lseq a blocksize = div_mul_lt blocksize i (len / blocksize); let j = i / blocksize in let b: lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in b let get_last_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) : lseq a (len % blocksize) = let rem = len % blocksize in let b: lseq a rem = Seq.slice inp (len - rem) len in b val repeati_extensionality: #a:Type0 -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g i acc)) (ensures Loops.repeati n f acc0 == Loops.repeati n g acc0) val repeat_right_extensionality: n:nat -> lo:nat -> a_f:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> a_g:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> f:(i:nat{lo <= i /\ i < lo + n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo <= i /\ i < lo + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f lo -> Lemma (requires (forall (i:nat{lo <= i /\ i <= lo + n}). a_f i == a_g i) /\ (forall (i:nat{lo <= i /\ i < lo + n}) (acc:a_f i). f i acc == g i acc)) (ensures Loops.repeat_right lo (lo + n) a_f f acc0 == Loops.repeat_right lo (lo + n) a_g g acc0) // Loops.repeat_gen n a_f f acc0 == // Loops.repeat_right lo_g (lo_g + n) a_g g acc0) val repeat_gen_right_extensionality: n:nat -> lo_g:nat -> a_f:(i:nat{i <= n} -> Type) -> a_g:(i:nat{lo_g <= i /\ i <= lo_g + n} -> Type) -> f:(i:nat{i < n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f 0 -> Lemma (requires (forall (i:nat{i <= n}). a_f i == a_g (lo_g + i)) /\ (forall (i:nat{i < n}) (acc:a_f i). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n a_f f acc0 == Loops.repeat_right lo_g (lo_g + n) a_g g acc0) // Loops.repeati n a f acc0 == // Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0 val repeati_right_extensionality: #a:Type -> n:nat -> lo_g:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n (Loops.fixed_a a) f acc0 == Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0) /// A specialized version of the lemma above, for only shifting one computation, /// but specified using repeati instead val repeati_right_shift: #a:Type -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < 1 + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (i + 1) acc)) (ensures Loops.repeati n f (g 0 acc0) == Loops.repeati (n + 1) g acc0) /// /// `repeat_gen_blocks` is defined here to prove all the properties /// needed for `map_blocks` and `repeat_blocks` once /// let repeat_gen_blocks_f (#inp_t:Type0) (blocksize:size_pos) (mi:nat) (hi:nat) (n:nat{mi + n <= hi}) (inp:seq inp_t{length inp == n * blocksize}) (a:(i:nat{i <= hi} -> Type)) (f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i:nat{mi <= i /\ i < mi + n}) (acc:a i) : a (i + 1) = let i_b = i - mi in Math.Lemmas.lemma_mult_le_right blocksize (i_b + 1) n; let block = Seq.slice inp (i_b * blocksize) (i_b * blocksize + blocksize) in f i block acc //lo = 0 val repeat_gen_blocks_multi: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> a (mi + n) val lemma_repeat_gen_blocks_multi: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> Lemma (repeat_gen_blocks_multi #inp_t blocksize mi hi n inp a f acc0 == Loops.repeat_right mi (mi + n) a (repeat_gen_blocks_f blocksize mi hi n inp a f) acc0) val repeat_gen_blocks: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq inp_t{mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acci:a mi -> c val lemma_repeat_gen_blocks: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq inp_t{mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acc0:a mi -> Lemma (let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_div nb blocksize; Math.Lemmas.cancel_mul_mod nb blocksize; let acc = repeat_gen_blocks_multi #inp_t blocksize mi hi nb blocks a f acc0 in repeat_gen_blocks blocksize mi hi inp a f l acc0 == l (mi + nb) rem last acc) val repeat_gen_blocks_multi_extensionality_zero: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi_f:nat -> hi_g:nat -> n:nat{mi + n <= hi_f /\ n <= hi_g} -> inp:seq inp_t{length inp == n * blocksize} -> a_f:(i:nat{i <= hi_f} -> Type) -> a_g:(i:nat{i <= hi_g} -> Type) -> f:(i:nat{i < hi_f} -> lseq inp_t blocksize -> a_f i -> a_f (i + 1)) -> g:(i:nat{i < hi_g} -> lseq inp_t blocksize -> a_g i -> a_g (i + 1)) -> acc0:a_f mi -> Lemma (requires (forall (i:nat{i <= n}). a_f (mi + i) == a_g i) /\ (forall (i:nat{i < n}) (block:lseq inp_t blocksize) (acc:a_f (mi + i)). f (mi + i) block acc == g i block acc)) (ensures repeat_gen_blocks_multi blocksize mi hi_f n inp a_f f acc0 == repeat_gen_blocks_multi blocksize 0 hi_g n inp a_g g acc0) val repeat_gen_blocks_extensionality_zero: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi_f:nat -> hi_g:nat -> n:nat{mi + n <= hi_f /\ n <= hi_g} -> inp:seq inp_t{n == length inp / blocksize} -> a_f:(i:nat{i <= hi_f} -> Type) -> a_g:(i:nat{i <= hi_g} -> Type) -> f:(i:nat{i < hi_f} -> lseq inp_t blocksize -> a_f i -> a_f (i + 1)) -> l_f:(i:nat{i <= hi_f} -> len:nat{len < blocksize} -> lseq inp_t len -> a_f i -> c) -> g:(i:nat{i < hi_g} -> lseq inp_t blocksize -> a_g i -> a_g (i + 1)) -> l_g:(i:nat{i <= hi_g} -> len:nat{len < blocksize} -> lseq inp_t len -> a_g i -> c) -> acc0:a_f mi -> Lemma (requires (forall (i:nat{i <= n}). a_f (mi + i) == a_g i) /\ (forall (i:nat{i < n}) (block:lseq inp_t blocksize) (acc:a_f (mi + i)). f (mi + i) block acc == g i block acc) /\ (forall (i:nat{i <= n}) (len:nat{len < blocksize}) (block:lseq inp_t len) (acc:a_f (mi + i)). l_f (mi + i) len block acc == l_g i len block acc)) (ensures repeat_gen_blocks blocksize mi hi_f inp a_f f l_f acc0 == repeat_gen_blocks blocksize 0 hi_g inp a_g g l_g acc0) val len0_div_bs: blocksize:pos -> len:nat -> len0:nat -> Lemma (requires len0 <= len /\ len0 % blocksize == 0) (ensures len0 / blocksize + (len - len0) / blocksize == len / blocksize) val split_len_lemma0: blocksize:pos -> n:nat -> len0:nat -> Lemma (requires len0 <= n * blocksize /\ len0 % blocksize = 0) (ensures (let len = n * blocksize in let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in len % blocksize = 0 /\ len1 % blocksize = 0 /\ n0 + n1 = n /\ n0 * blocksize = len0 /\ n1 * blocksize = len1)) val split_len_lemma: blocksize:pos -> len:nat -> len0:nat -> Lemma (requires len0 <= len /\ len0 % blocksize = 0) (ensures (let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in let n = len / blocksize in len % blocksize = len1 % blocksize /\ n0 * blocksize = len0 /\ n0 + n1 = n)) val repeat_gen_blocks_multi_split: #inp_t:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize == 0} -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{len0 <= length inp /\ length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> Lemma (let len = length inp in let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in split_len_lemma0 blocksize n len0; let t0 = Seq.slice inp 0 len0 in let t1 = Seq.slice inp len0 len in let acc : a (mi + n0) = repeat_gen_blocks_multi blocksize mi hi n0 t0 a f acc0 in repeat_gen_blocks_multi blocksize mi hi n inp a f acc0 == repeat_gen_blocks_multi blocksize (mi + n0) hi n1 t1 a f acc) val repeat_gen_blocks_split: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize == 0} -> hi:nat -> mi:nat{mi <= hi} -> inp:seq inp_t{len0 <= length inp /\ mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acc0:a mi -> Lemma (let len = length inp in let n = len / blocksize in let n0 = len0 / blocksize in split_len_lemma blocksize len len0; let t0 = Seq.slice inp 0 len0 in let t1 = Seq.slice inp len0 len in let acc : a (mi + n0) = repeat_gen_blocks_multi blocksize mi hi n0 t0 a f acc0 in repeat_gen_blocks blocksize mi hi inp a f l acc0 == repeat_gen_blocks blocksize (mi + n0) hi t1 a f l acc) /// /// Properties related to the repeat_blocks combinator /// val repeat_blocks_extensionality: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f1:(lseq a blocksize -> b -> b) -> f2:(lseq a blocksize -> b -> b) -> l1:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> l2:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (requires (forall (block:lseq a blocksize) (acc:b). f1 block acc == f2 block acc) /\ (forall (rem:nat{rem < blocksize}) (last:lseq a rem) (acc:b). l1 rem last acc == l2 rem last acc)) (ensures repeat_blocks blocksize inp f1 l1 acc0 == repeat_blocks blocksize inp f2 l2 acc0) val lemma_repeat_blocks_via_multi: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_mod nb blocksize; let acc = repeat_blocks_multi blocksize blocks f acc0 in repeat_blocks #a #b blocksize inp f l acc0 == l rem last acc) val repeat_blocks_multi_is_repeat_gen_blocks_multi: #a:Type0 -> #b:Type0 -> hi:nat -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0 /\ length inp / blocksize <= hi} -> f:(lseq a blocksize -> b -> b) -> acc0:b -> Lemma (let n = length inp / blocksize in Math.Lemmas.div_exact_r (length inp) blocksize; repeat_blocks_multi #a #b blocksize inp f acc0 == repeat_gen_blocks_multi #a blocksize 0 hi n inp (Loops.fixed_a b) (Loops.fixed_i f) acc0) val repeat_blocks_is_repeat_gen_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> hi:nat -> blocksize:size_pos -> inp:seq a{length inp / blocksize <= hi} -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (repeat_blocks #a #b #c blocksize inp f l acc0 == repeat_gen_blocks #a #c blocksize 0 hi inp (Loops.fixed_a b) (Loops.fixed_i f) (Loops.fixed_i l) acc0) val repeat_blocks_multi_split: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize = 0} -> inp:seq a{len0 <= length inp /\ length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> acc0:b -> Lemma (let len = length inp in Math.Lemmas.lemma_div_exact len blocksize; split_len_lemma0 blocksize (len / blocksize) len0; Math.Lemmas.swap_mul blocksize (len / blocksize); repeat_blocks_multi blocksize inp f acc0 == repeat_blocks_multi blocksize (Seq.slice inp len0 len) f (repeat_blocks_multi blocksize (Seq.slice inp 0 len0) f acc0)) val repeat_blocks_split: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize = 0} -> inp:seq a{len0 <= length inp} -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (let len = length inp in split_len_lemma blocksize len len0; repeat_blocks blocksize inp f l acc0 == repeat_blocks blocksize (Seq.slice inp len0 len) f l (repeat_blocks_multi blocksize (Seq.slice inp 0 len0) f acc0)) /// val repeat_blocks_multi_extensionality: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> g:(lseq a blocksize -> b -> b) -> init:b -> Lemma (requires (forall (block:lseq a blocksize) (acc:b). f block acc == g block acc)) (ensures repeat_blocks_multi blocksize inp f init == repeat_blocks_multi blocksize inp g init) /// Properties related to the map_blocks combinator /// val map_blocks_multi_extensionality: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> g:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Lemma (requires (forall (i:nat{i < max}) (b_v:lseq a blocksize). f i b_v == g i b_v)) (ensures map_blocks_multi blocksize max n inp f == map_blocks_multi blocksize max n inp g) val map_blocks_extensionality: #a:Type0 -> blocksize:size_pos -> inp:seq a -> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> l_f:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> g:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> l_g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> Lemma (requires (let n = length inp / blocksize in (forall (i:nat{i < n}) (b_v:lseq a blocksize). f i b_v == g i b_v) /\ (forall (rem:nat{rem < blocksize}) (b_v:lseq a rem). l_f n rem b_v == l_g n rem b_v))) (ensures map_blocks blocksize inp f l_f == map_blocks blocksize inp g l_g) /// /// New definition of `map_blocks` that takes extra parameter `acc`. /// When `acc` = Seq.empty, map_blocks == map_blocks_acc /// let repeat_gen_blocks_map_f (#a:Type0) (blocksize:size_pos) (hi:nat) (f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < hi}) (block:lseq a blocksize) (acc:map_blocks_a a blocksize hi i) : map_blocks_a a blocksize hi (i + 1) = Seq.append acc (f i block) let repeat_gen_blocks_map_l (#a:Type0) (blocksize:size_pos) (hi:nat) (l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem)) (i:nat{i <= hi}) (rem:nat{rem < blocksize}) (block_l:lseq a rem) (acc:map_blocks_a a blocksize hi i) : seq a = if rem > 0 then Seq.append acc (l i rem block_l) else acc val repeat_gen_blocks_map_l_length: #a:Type0 -> blocksize:size_pos -> hi:nat -> l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem) -> i:nat{i <= hi} -> rem:nat{rem < blocksize} -> block_l:lseq a rem -> acc:map_blocks_a a blocksize hi i -> Lemma (length (repeat_gen_blocks_map_l blocksize hi l i rem block_l acc) == i * blocksize + rem) val map_blocks_multi_acc: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq a{length inp == n * blocksize} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> acc0:map_blocks_a a blocksize hi mi -> out:seq a {length out == length acc0 + length inp} val map_blocks_acc: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq a{mi + length inp / blocksize <= hi} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem) -> acc0:map_blocks_a a blocksize hi mi -> seq a val map_blocks_acc_length: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq a{mi + length inp / blocksize <= hi} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem) -> acc0:map_blocks_a a blocksize hi mi -> Lemma (length (map_blocks_acc blocksize mi hi inp f l acc0) == length acc0 + length inp) [SMTPat (map_blocks_acc blocksize mi hi inp f l acc0)] val map_blocks_multi_acc_is_repeat_gen_blocks_multi: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq a{length inp == n * blocksize} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> acc0:map_blocks_a a blocksize hi mi -> Lemma (map_blocks_multi_acc #a blocksize mi hi n inp f acc0 == repeat_gen_blocks_multi #a blocksize mi hi n inp (map_blocks_a a blocksize hi) (repeat_gen_blocks_map_f blocksize hi f) acc0) val map_blocks_acc_is_repeat_gen_blocks: #a:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq a{mi + length inp / blocksize <= hi} -> f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize) -> l:(i:nat{i <= hi} -> rem:nat{rem < blocksize} -> lseq a rem -> lseq a rem) -> acc0:map_blocks_a a blocksize hi mi -> Lemma (map_blocks_acc #a blocksize mi hi inp f l acc0 == repeat_gen_blocks #a blocksize mi hi inp (map_blocks_a a blocksize hi) (repeat_gen_blocks_map_f blocksize hi f) (repeat_gen_blocks_map_l blocksize hi l) acc0) let f_shift (#a:Type0) (blocksize:size_pos) (mi:nat) (hi:nat) (n:nat{mi + n <= hi}) (f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < n}) = f (mi + i)
false
false
Lib.Sequence.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val l_shift : blocksize: Lib.IntTypes.size_pos -> mi: Prims.nat -> hi: Prims.nat -> n: Prims.nat{mi + n <= hi} -> l: (i: Prims.nat{i <= hi} -> rem: Prims.nat{rem < blocksize} -> _: Lib.Sequence.lseq a rem -> Lib.Sequence.lseq a rem) -> i: Prims.nat{i <= n} -> rem: Prims.nat{rem < blocksize} -> _: Lib.Sequence.lseq a rem -> Lib.Sequence.lseq a rem
[]
Lib.Sequence.Lemmas.l_shift
{ "file_name": "lib/Lib.Sequence.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> mi: Prims.nat -> hi: Prims.nat -> n: Prims.nat{mi + n <= hi} -> l: (i: Prims.nat{i <= hi} -> rem: Prims.nat{rem < blocksize} -> _: Lib.Sequence.lseq a rem -> Lib.Sequence.lseq a rem) -> i: Prims.nat{i <= n} -> rem: Prims.nat{rem < blocksize} -> _: Lib.Sequence.lseq a rem -> Lib.Sequence.lseq a rem
{ "end_col": 107, "end_line": 613, "start_col": 97, "start_line": 613 }
Prims.Tot
val get_block_s (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (i: nat{i < (len / blocksize) * blocksize}) : lseq a blocksize
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_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_block_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (i:nat{i < len / blocksize * blocksize}) : lseq a blocksize = div_mul_lt blocksize i (len / blocksize); let j = i / blocksize in let b: lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in b
val get_block_s (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (i: nat{i < (len / blocksize) * blocksize}) : lseq a blocksize let get_block_s (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (i: nat{i < (len / blocksize) * blocksize}) : lseq a blocksize =
false
null
false
div_mul_lt blocksize i (len / blocksize); let j = i / blocksize in let b:lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in b
{ "checked_file": "Lib.Sequence.Lemmas.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.Lemmas.fsti" }
[ "total" ]
[ "Prims.nat", "Lib.IntTypes.size_pos", "Lib.Sequence.seq", "Prims.eq2", "Lib.Sequence.length", "Prims.b2t", "Prims.op_LessThan", "FStar.Mul.op_Star", "Prims.op_Division", "Lib.Sequence.lseq", "FStar.Seq.Base.slice", "Prims.op_Addition", "Prims.int", "Prims.unit", "Lib.Sequence.div_mul_lt" ]
[]
module Lib.Sequence.Lemmas open FStar.Mul open Lib.IntTypes open Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 \ --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence +Lib.Sequence.Lemmas'" let get_block_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (i:nat{i < len / blocksize * blocksize}) : lseq a blocksize
false
false
Lib.Sequence.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_block_s (#a: Type) (#len: nat) (blocksize: size_pos) (inp: seq a {length inp == len}) (i: nat{i < (len / blocksize) * blocksize}) : lseq a blocksize
[]
Lib.Sequence.Lemmas.get_block_s
{ "file_name": "lib/Lib.Sequence.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> inp: Lib.Sequence.seq a {Lib.Sequence.length inp == len} -> i: Prims.nat{i < (len / blocksize) * blocksize} -> Lib.Sequence.lseq a blocksize
{ "end_col": 3, "end_line": 24, "start_col": 2, "start_line": 21 }
Prims.Tot
val repeat_gen_blocks_map_f (#a: Type0) (blocksize: size_pos) (hi: nat) (f: (i: nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i: nat{i < hi}) (block: lseq a blocksize) (acc: map_blocks_a a blocksize hi i) : map_blocks_a a blocksize hi (i + 1)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repeat_gen_blocks_map_f (#a:Type0) (blocksize:size_pos) (hi:nat) (f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < hi}) (block:lseq a blocksize) (acc:map_blocks_a a blocksize hi i) : map_blocks_a a blocksize hi (i + 1) = Seq.append acc (f i block)
val repeat_gen_blocks_map_f (#a: Type0) (blocksize: size_pos) (hi: nat) (f: (i: nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i: nat{i < hi}) (block: lseq a blocksize) (acc: map_blocks_a a blocksize hi i) : map_blocks_a a blocksize hi (i + 1) let repeat_gen_blocks_map_f (#a: Type0) (blocksize: size_pos) (hi: nat) (f: (i: nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i: nat{i < hi}) (block: lseq a blocksize) (acc: map_blocks_a a blocksize hi i) : map_blocks_a a blocksize hi (i + 1) =
false
null
false
Seq.append acc (f i block)
{ "checked_file": "Lib.Sequence.Lemmas.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.Lemmas.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Lib.Sequence.lseq", "Lib.Sequence.map_blocks_a", "FStar.Seq.Base.append", "Prims.op_Addition" ]
[]
module Lib.Sequence.Lemmas open FStar.Mul open Lib.IntTypes open Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 \ --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence +Lib.Sequence.Lemmas'" let get_block_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (i:nat{i < len / blocksize * blocksize}) : lseq a blocksize = div_mul_lt blocksize i (len / blocksize); let j = i / blocksize in let b: lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in b let get_last_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) : lseq a (len % blocksize) = let rem = len % blocksize in let b: lseq a rem = Seq.slice inp (len - rem) len in b val repeati_extensionality: #a:Type0 -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g i acc)) (ensures Loops.repeati n f acc0 == Loops.repeati n g acc0) val repeat_right_extensionality: n:nat -> lo:nat -> a_f:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> a_g:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> f:(i:nat{lo <= i /\ i < lo + n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo <= i /\ i < lo + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f lo -> Lemma (requires (forall (i:nat{lo <= i /\ i <= lo + n}). a_f i == a_g i) /\ (forall (i:nat{lo <= i /\ i < lo + n}) (acc:a_f i). f i acc == g i acc)) (ensures Loops.repeat_right lo (lo + n) a_f f acc0 == Loops.repeat_right lo (lo + n) a_g g acc0) // Loops.repeat_gen n a_f f acc0 == // Loops.repeat_right lo_g (lo_g + n) a_g g acc0) val repeat_gen_right_extensionality: n:nat -> lo_g:nat -> a_f:(i:nat{i <= n} -> Type) -> a_g:(i:nat{lo_g <= i /\ i <= lo_g + n} -> Type) -> f:(i:nat{i < n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f 0 -> Lemma (requires (forall (i:nat{i <= n}). a_f i == a_g (lo_g + i)) /\ (forall (i:nat{i < n}) (acc:a_f i). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n a_f f acc0 == Loops.repeat_right lo_g (lo_g + n) a_g g acc0) // Loops.repeati n a f acc0 == // Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0 val repeati_right_extensionality: #a:Type -> n:nat -> lo_g:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n (Loops.fixed_a a) f acc0 == Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0) /// A specialized version of the lemma above, for only shifting one computation, /// but specified using repeati instead val repeati_right_shift: #a:Type -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < 1 + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (i + 1) acc)) (ensures Loops.repeati n f (g 0 acc0) == Loops.repeati (n + 1) g acc0) /// /// `repeat_gen_blocks` is defined here to prove all the properties /// needed for `map_blocks` and `repeat_blocks` once /// let repeat_gen_blocks_f (#inp_t:Type0) (blocksize:size_pos) (mi:nat) (hi:nat) (n:nat{mi + n <= hi}) (inp:seq inp_t{length inp == n * blocksize}) (a:(i:nat{i <= hi} -> Type)) (f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i:nat{mi <= i /\ i < mi + n}) (acc:a i) : a (i + 1) = let i_b = i - mi in Math.Lemmas.lemma_mult_le_right blocksize (i_b + 1) n; let block = Seq.slice inp (i_b * blocksize) (i_b * blocksize + blocksize) in f i block acc //lo = 0 val repeat_gen_blocks_multi: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> a (mi + n) val lemma_repeat_gen_blocks_multi: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> Lemma (repeat_gen_blocks_multi #inp_t blocksize mi hi n inp a f acc0 == Loops.repeat_right mi (mi + n) a (repeat_gen_blocks_f blocksize mi hi n inp a f) acc0) val repeat_gen_blocks: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq inp_t{mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acci:a mi -> c val lemma_repeat_gen_blocks: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi:nat -> inp:seq inp_t{mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acc0:a mi -> Lemma (let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_div nb blocksize; Math.Lemmas.cancel_mul_mod nb blocksize; let acc = repeat_gen_blocks_multi #inp_t blocksize mi hi nb blocks a f acc0 in repeat_gen_blocks blocksize mi hi inp a f l acc0 == l (mi + nb) rem last acc) val repeat_gen_blocks_multi_extensionality_zero: #inp_t:Type0 -> blocksize:size_pos -> mi:nat -> hi_f:nat -> hi_g:nat -> n:nat{mi + n <= hi_f /\ n <= hi_g} -> inp:seq inp_t{length inp == n * blocksize} -> a_f:(i:nat{i <= hi_f} -> Type) -> a_g:(i:nat{i <= hi_g} -> Type) -> f:(i:nat{i < hi_f} -> lseq inp_t blocksize -> a_f i -> a_f (i + 1)) -> g:(i:nat{i < hi_g} -> lseq inp_t blocksize -> a_g i -> a_g (i + 1)) -> acc0:a_f mi -> Lemma (requires (forall (i:nat{i <= n}). a_f (mi + i) == a_g i) /\ (forall (i:nat{i < n}) (block:lseq inp_t blocksize) (acc:a_f (mi + i)). f (mi + i) block acc == g i block acc)) (ensures repeat_gen_blocks_multi blocksize mi hi_f n inp a_f f acc0 == repeat_gen_blocks_multi blocksize 0 hi_g n inp a_g g acc0) val repeat_gen_blocks_extensionality_zero: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> mi:nat -> hi_f:nat -> hi_g:nat -> n:nat{mi + n <= hi_f /\ n <= hi_g} -> inp:seq inp_t{n == length inp / blocksize} -> a_f:(i:nat{i <= hi_f} -> Type) -> a_g:(i:nat{i <= hi_g} -> Type) -> f:(i:nat{i < hi_f} -> lseq inp_t blocksize -> a_f i -> a_f (i + 1)) -> l_f:(i:nat{i <= hi_f} -> len:nat{len < blocksize} -> lseq inp_t len -> a_f i -> c) -> g:(i:nat{i < hi_g} -> lseq inp_t blocksize -> a_g i -> a_g (i + 1)) -> l_g:(i:nat{i <= hi_g} -> len:nat{len < blocksize} -> lseq inp_t len -> a_g i -> c) -> acc0:a_f mi -> Lemma (requires (forall (i:nat{i <= n}). a_f (mi + i) == a_g i) /\ (forall (i:nat{i < n}) (block:lseq inp_t blocksize) (acc:a_f (mi + i)). f (mi + i) block acc == g i block acc) /\ (forall (i:nat{i <= n}) (len:nat{len < blocksize}) (block:lseq inp_t len) (acc:a_f (mi + i)). l_f (mi + i) len block acc == l_g i len block acc)) (ensures repeat_gen_blocks blocksize mi hi_f inp a_f f l_f acc0 == repeat_gen_blocks blocksize 0 hi_g inp a_g g l_g acc0) val len0_div_bs: blocksize:pos -> len:nat -> len0:nat -> Lemma (requires len0 <= len /\ len0 % blocksize == 0) (ensures len0 / blocksize + (len - len0) / blocksize == len / blocksize) val split_len_lemma0: blocksize:pos -> n:nat -> len0:nat -> Lemma (requires len0 <= n * blocksize /\ len0 % blocksize = 0) (ensures (let len = n * blocksize in let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in len % blocksize = 0 /\ len1 % blocksize = 0 /\ n0 + n1 = n /\ n0 * blocksize = len0 /\ n1 * blocksize = len1)) val split_len_lemma: blocksize:pos -> len:nat -> len0:nat -> Lemma (requires len0 <= len /\ len0 % blocksize = 0) (ensures (let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in let n = len / blocksize in len % blocksize = len1 % blocksize /\ n0 * blocksize = len0 /\ n0 + n1 = n)) val repeat_gen_blocks_multi_split: #inp_t:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize == 0} -> mi:nat -> hi:nat -> n:nat{mi + n <= hi} -> inp:seq inp_t{len0 <= length inp /\ length inp == n * blocksize} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> acc0:a mi -> Lemma (let len = length inp in let len1 = len - len0 in let n0 = len0 / blocksize in let n1 = len1 / blocksize in split_len_lemma0 blocksize n len0; let t0 = Seq.slice inp 0 len0 in let t1 = Seq.slice inp len0 len in let acc : a (mi + n0) = repeat_gen_blocks_multi blocksize mi hi n0 t0 a f acc0 in repeat_gen_blocks_multi blocksize mi hi n inp a f acc0 == repeat_gen_blocks_multi blocksize (mi + n0) hi n1 t1 a f acc) val repeat_gen_blocks_split: #inp_t:Type0 -> #c:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize == 0} -> hi:nat -> mi:nat{mi <= hi} -> inp:seq inp_t{len0 <= length inp /\ mi + length inp / blocksize <= hi} -> a:(i:nat{i <= hi} -> Type) -> f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1)) -> l:(i:nat{i <= hi} -> len:nat{len < blocksize} -> lseq inp_t len -> a i -> c) -> acc0:a mi -> Lemma (let len = length inp in let n = len / blocksize in let n0 = len0 / blocksize in split_len_lemma blocksize len len0; let t0 = Seq.slice inp 0 len0 in let t1 = Seq.slice inp len0 len in let acc : a (mi + n0) = repeat_gen_blocks_multi blocksize mi hi n0 t0 a f acc0 in repeat_gen_blocks blocksize mi hi inp a f l acc0 == repeat_gen_blocks blocksize (mi + n0) hi t1 a f l acc) /// /// Properties related to the repeat_blocks combinator /// val repeat_blocks_extensionality: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f1:(lseq a blocksize -> b -> b) -> f2:(lseq a blocksize -> b -> b) -> l1:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> l2:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (requires (forall (block:lseq a blocksize) (acc:b). f1 block acc == f2 block acc) /\ (forall (rem:nat{rem < blocksize}) (last:lseq a rem) (acc:b). l1 rem last acc == l2 rem last acc)) (ensures repeat_blocks blocksize inp f1 l1 acc0 == repeat_blocks blocksize inp f2 l2 acc0) val lemma_repeat_blocks_via_multi: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> inp:seq a -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (let len = length inp in let nb = len / blocksize in let rem = len % blocksize in let blocks = Seq.slice inp 0 (nb * blocksize) in let last = Seq.slice inp (nb * blocksize) len in Math.Lemmas.cancel_mul_mod nb blocksize; let acc = repeat_blocks_multi blocksize blocks f acc0 in repeat_blocks #a #b blocksize inp f l acc0 == l rem last acc) val repeat_blocks_multi_is_repeat_gen_blocks_multi: #a:Type0 -> #b:Type0 -> hi:nat -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0 /\ length inp / blocksize <= hi} -> f:(lseq a blocksize -> b -> b) -> acc0:b -> Lemma (let n = length inp / blocksize in Math.Lemmas.div_exact_r (length inp) blocksize; repeat_blocks_multi #a #b blocksize inp f acc0 == repeat_gen_blocks_multi #a blocksize 0 hi n inp (Loops.fixed_a b) (Loops.fixed_i f) acc0) val repeat_blocks_is_repeat_gen_blocks: #a:Type0 -> #b:Type0 -> #c:Type0 -> hi:nat -> blocksize:size_pos -> inp:seq a{length inp / blocksize <= hi} -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (repeat_blocks #a #b #c blocksize inp f l acc0 == repeat_gen_blocks #a #c blocksize 0 hi inp (Loops.fixed_a b) (Loops.fixed_i f) (Loops.fixed_i l) acc0) val repeat_blocks_multi_split: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize = 0} -> inp:seq a{len0 <= length inp /\ length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> acc0:b -> Lemma (let len = length inp in Math.Lemmas.lemma_div_exact len blocksize; split_len_lemma0 blocksize (len / blocksize) len0; Math.Lemmas.swap_mul blocksize (len / blocksize); repeat_blocks_multi blocksize inp f acc0 == repeat_blocks_multi blocksize (Seq.slice inp len0 len) f (repeat_blocks_multi blocksize (Seq.slice inp 0 len0) f acc0)) val repeat_blocks_split: #a:Type0 -> #b:Type0 -> #c:Type0 -> blocksize:size_pos -> len0:nat{len0 % blocksize = 0} -> inp:seq a{len0 <= length inp} -> f:(lseq a blocksize -> b -> b) -> l:(len:nat{len < blocksize} -> s:lseq a len -> b -> c) -> acc0:b -> Lemma (let len = length inp in split_len_lemma blocksize len len0; repeat_blocks blocksize inp f l acc0 == repeat_blocks blocksize (Seq.slice inp len0 len) f l (repeat_blocks_multi blocksize (Seq.slice inp 0 len0) f acc0)) /// val repeat_blocks_multi_extensionality: #a:Type0 -> #b:Type0 -> blocksize:size_pos -> inp:seq a{length inp % blocksize = 0} -> f:(lseq a blocksize -> b -> b) -> g:(lseq a blocksize -> b -> b) -> init:b -> Lemma (requires (forall (block:lseq a blocksize) (acc:b). f block acc == g block acc)) (ensures repeat_blocks_multi blocksize inp f init == repeat_blocks_multi blocksize inp g init) /// Properties related to the map_blocks combinator /// val map_blocks_multi_extensionality: #a:Type0 -> blocksize:size_pos -> max:nat -> n:nat{n <= max} -> inp:seq a{length inp == max * blocksize} -> f:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> g:(i:nat{i < max} -> lseq a blocksize -> lseq a blocksize) -> Lemma (requires (forall (i:nat{i < max}) (b_v:lseq a blocksize). f i b_v == g i b_v)) (ensures map_blocks_multi blocksize max n inp f == map_blocks_multi blocksize max n inp g) val map_blocks_extensionality: #a:Type0 -> blocksize:size_pos -> inp:seq a -> f:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> l_f:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> g:(block (length inp) blocksize -> lseq a blocksize -> lseq a blocksize) -> l_g:(last (length inp) blocksize -> rem:size_nat{rem < blocksize} -> s:lseq a rem -> lseq a rem) -> Lemma (requires (let n = length inp / blocksize in (forall (i:nat{i < n}) (b_v:lseq a blocksize). f i b_v == g i b_v) /\ (forall (rem:nat{rem < blocksize}) (b_v:lseq a rem). l_f n rem b_v == l_g n rem b_v))) (ensures map_blocks blocksize inp f l_f == map_blocks blocksize inp g l_g) /// /// New definition of `map_blocks` that takes extra parameter `acc`. /// When `acc` = Seq.empty, map_blocks == map_blocks_acc /// let repeat_gen_blocks_map_f (#a:Type0) (blocksize:size_pos) (hi:nat) (f:(i:nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i:nat{i < hi}) (block:lseq a blocksize) (acc:map_blocks_a a blocksize hi i) : map_blocks_a a blocksize hi (i + 1)
false
false
Lib.Sequence.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeat_gen_blocks_map_f (#a: Type0) (blocksize: size_pos) (hi: nat) (f: (i: nat{i < hi} -> lseq a blocksize -> lseq a blocksize)) (i: nat{i < hi}) (block: lseq a blocksize) (acc: map_blocks_a a blocksize hi i) : map_blocks_a a blocksize hi (i + 1)
[]
Lib.Sequence.Lemmas.repeat_gen_blocks_map_f
{ "file_name": "lib/Lib.Sequence.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> hi: Prims.nat -> f: (i: Prims.nat{i < hi} -> _: Lib.Sequence.lseq a blocksize -> Lib.Sequence.lseq a blocksize) -> i: Prims.nat{i < hi} -> block: Lib.Sequence.lseq a blocksize -> acc: Lib.Sequence.map_blocks_a a blocksize hi i -> Lib.Sequence.map_blocks_a a blocksize hi (i + 1)
{ "end_col": 29, "end_line": 510, "start_col": 3, "start_line": 510 }
Prims.Tot
val repeat_gen_blocks_f (#inp_t: Type0) (blocksize: size_pos) (mi hi: nat) (n: nat{mi + n <= hi}) (inp: seq inp_t {length inp == n * blocksize}) (a: (i: nat{i <= hi} -> Type)) (f: (i: nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i: nat{mi <= i /\ i < mi + n}) (acc: a i) : a (i + 1)
[ { "abbrev": true, "full_module": "Lib.LoopCombinators", "short_module": "Loops" }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "Lib.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let repeat_gen_blocks_f (#inp_t:Type0) (blocksize:size_pos) (mi:nat) (hi:nat) (n:nat{mi + n <= hi}) (inp:seq inp_t{length inp == n * blocksize}) (a:(i:nat{i <= hi} -> Type)) (f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i:nat{mi <= i /\ i < mi + n}) (acc:a i) : a (i + 1) = let i_b = i - mi in Math.Lemmas.lemma_mult_le_right blocksize (i_b + 1) n; let block = Seq.slice inp (i_b * blocksize) (i_b * blocksize + blocksize) in f i block acc
val repeat_gen_blocks_f (#inp_t: Type0) (blocksize: size_pos) (mi hi: nat) (n: nat{mi + n <= hi}) (inp: seq inp_t {length inp == n * blocksize}) (a: (i: nat{i <= hi} -> Type)) (f: (i: nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i: nat{mi <= i /\ i < mi + n}) (acc: a i) : a (i + 1) let repeat_gen_blocks_f (#inp_t: Type0) (blocksize: size_pos) (mi hi: nat) (n: nat{mi + n <= hi}) (inp: seq inp_t {length inp == n * blocksize}) (a: (i: nat{i <= hi} -> Type)) (f: (i: nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i: nat{mi <= i /\ i < mi + n}) (acc: a i) : a (i + 1) =
false
null
false
let i_b = i - mi in Math.Lemmas.lemma_mult_le_right blocksize (i_b + 1) n; let block = Seq.slice inp (i_b * blocksize) (i_b * blocksize + blocksize) in f i block acc
{ "checked_file": "Lib.Sequence.Lemmas.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.LoopCombinators.fsti.checked", "Lib.IntTypes.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked" ], "interface_file": false, "source_file": "Lib.Sequence.Lemmas.fsti" }
[ "total" ]
[ "Lib.IntTypes.size_pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_Addition", "Lib.Sequence.seq", "Prims.eq2", "Prims.int", "Lib.Sequence.length", "FStar.Mul.op_Star", "Prims.op_LessThan", "Lib.Sequence.lseq", "Prims.l_and", "FStar.Seq.Base.seq", "FStar.Seq.Base.slice", "Prims.unit", "FStar.Math.Lemmas.lemma_mult_le_right", "Prims.op_Subtraction" ]
[]
module Lib.Sequence.Lemmas open FStar.Mul open Lib.IntTypes open Lib.Sequence module Loops = Lib.LoopCombinators #set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0 \ --using_facts_from '-* +Prims +FStar.Math.Lemmas +FStar.Seq +Lib.IntTypes +Lib.Sequence +Lib.Sequence.Lemmas'" let get_block_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) (i:nat{i < len / blocksize * blocksize}) : lseq a blocksize = div_mul_lt blocksize i (len / blocksize); let j = i / blocksize in let b: lseq a blocksize = Seq.slice inp (j * blocksize) ((j + 1) * blocksize) in b let get_last_s (#a:Type) (#len:nat) (blocksize:size_pos) (inp:seq a{length inp == len}) : lseq a (len % blocksize) = let rem = len % blocksize in let b: lseq a rem = Seq.slice inp (len - rem) len in b val repeati_extensionality: #a:Type0 -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g i acc)) (ensures Loops.repeati n f acc0 == Loops.repeati n g acc0) val repeat_right_extensionality: n:nat -> lo:nat -> a_f:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> a_g:(i:nat{lo <= i /\ i <= lo + n} -> Type) -> f:(i:nat{lo <= i /\ i < lo + n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo <= i /\ i < lo + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f lo -> Lemma (requires (forall (i:nat{lo <= i /\ i <= lo + n}). a_f i == a_g i) /\ (forall (i:nat{lo <= i /\ i < lo + n}) (acc:a_f i). f i acc == g i acc)) (ensures Loops.repeat_right lo (lo + n) a_f f acc0 == Loops.repeat_right lo (lo + n) a_g g acc0) // Loops.repeat_gen n a_f f acc0 == // Loops.repeat_right lo_g (lo_g + n) a_g g acc0) val repeat_gen_right_extensionality: n:nat -> lo_g:nat -> a_f:(i:nat{i <= n} -> Type) -> a_g:(i:nat{lo_g <= i /\ i <= lo_g + n} -> Type) -> f:(i:nat{i < n} -> a_f i -> a_f (i + 1)) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a_g i -> a_g (i + 1)) -> acc0:a_f 0 -> Lemma (requires (forall (i:nat{i <= n}). a_f i == a_g (lo_g + i)) /\ (forall (i:nat{i < n}) (acc:a_f i). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n a_f f acc0 == Loops.repeat_right lo_g (lo_g + n) a_g g acc0) // Loops.repeati n a f acc0 == // Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0 val repeati_right_extensionality: #a:Type -> n:nat -> lo_g:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{lo_g <= i /\ i < lo_g + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (lo_g + i) acc)) (ensures Loops.repeat_right 0 n (Loops.fixed_a a) f acc0 == Loops.repeat_right lo_g (lo_g + n) (Loops.fixed_a a) g acc0) /// A specialized version of the lemma above, for only shifting one computation, /// but specified using repeati instead val repeati_right_shift: #a:Type -> n:nat -> f:(i:nat{i < n} -> a -> a) -> g:(i:nat{i < 1 + n} -> a -> a) -> acc0:a -> Lemma (requires (forall (i:nat{i < n}) (acc:a). f i acc == g (i + 1) acc)) (ensures Loops.repeati n f (g 0 acc0) == Loops.repeati (n + 1) g acc0) /// /// `repeat_gen_blocks` is defined here to prove all the properties /// needed for `map_blocks` and `repeat_blocks` once /// let repeat_gen_blocks_f (#inp_t:Type0) (blocksize:size_pos) (mi:nat) (hi:nat) (n:nat{mi + n <= hi}) (inp:seq inp_t{length inp == n * blocksize}) (a:(i:nat{i <= hi} -> Type)) (f:(i:nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i:nat{mi <= i /\ i < mi + n})
false
false
Lib.Sequence.Lemmas.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val repeat_gen_blocks_f (#inp_t: Type0) (blocksize: size_pos) (mi hi: nat) (n: nat{mi + n <= hi}) (inp: seq inp_t {length inp == n * blocksize}) (a: (i: nat{i <= hi} -> Type)) (f: (i: nat{i < hi} -> lseq inp_t blocksize -> a i -> a (i + 1))) (i: nat{mi <= i /\ i < mi + n}) (acc: a i) : a (i + 1)
[]
Lib.Sequence.Lemmas.repeat_gen_blocks_f
{ "file_name": "lib/Lib.Sequence.Lemmas.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
blocksize: Lib.IntTypes.size_pos -> mi: Prims.nat -> hi: Prims.nat -> n: Prims.nat{mi + n <= hi} -> inp: Lib.Sequence.seq inp_t {Lib.Sequence.length inp == n * blocksize} -> a: (i: Prims.nat{i <= hi} -> Type) -> f: (i: Prims.nat{i < hi} -> _: Lib.Sequence.lseq inp_t blocksize -> _: a i -> a (i + 1)) -> i: Prims.nat{mi <= i /\ i < mi + n} -> acc: a i -> a (i + 1)
{ "end_col": 15, "end_line": 133, "start_col": 1, "start_line": 129 }
Steel.ST.Effect.ST
val alloc (#a:Type) (#pcm:pcm a) (x:a) : ST (ref a pcm) emp (fun r -> pts_to r x) (requires pcm.refine x) (ensures fun _ -> True)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let alloc x = C.coerce_steel (fun _ -> P.alloc x)
val alloc (#a:Type) (#pcm:pcm a) (x:a) : ST (ref a pcm) emp (fun r -> pts_to r x) (requires pcm.refine x) (ensures fun _ -> True) let alloc x =
true
null
false
C.coerce_steel (fun _ -> P.alloc x)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "FStar.PCM.pcm", "Steel.ST.Coercions.coerce_steel", "Steel.Memory.ref", "Steel.Effect.Common.emp", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "Steel.Effect.Common.vprop", "FStar.PCM.__proj__Mkpcm__item__refine", "Prims.l_True", "Prims.unit", "Steel.PCMReference.alloc" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1)
false
false
Steel.ST.PCMReference.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 alloc (#a:Type) (#pcm:pcm a) (x:a) : ST (ref a pcm) emp (fun r -> pts_to r x) (requires pcm.refine x) (ensures fun _ -> True)
[]
Steel.ST.PCMReference.alloc
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
x: a -> Steel.ST.Effect.ST (Steel.Memory.ref a pcm)
{ "end_col": 49, "end_line": 10, "start_col": 14, "start_line": 10 }
Steel.ST.Effect.ST
val write (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) (v1:a) : ST unit (pts_to r v0) (fun _ -> pts_to r v1) (requires frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ -> True)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1)
val write (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) (v1:a) : ST unit (pts_to r v0) (fun _ -> pts_to r v1) (requires frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ -> True) let write r v0 v1 =
true
null
false
C.coerce_steel (fun _ -> P.write r v0 v1)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.ST.Coercions.coerce_steel", "Prims.unit", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.vprop", "Prims.l_and", "FStar.PCM.frame_preserving", "FStar.PCM.__proj__Mkpcm__item__refine", "Prims.l_True", "Steel.PCMReference.write" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0)
false
false
Steel.ST.PCMReference.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 write (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) (v1:a) : ST unit (pts_to r v0) (fun _ -> pts_to r v1) (requires frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ -> True)
[]
Steel.ST.PCMReference.write
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a pcm -> v0: FStar.Ghost.erased a -> v1: a -> Steel.ST.Effect.ST Prims.unit
{ "end_col": 61, "end_line": 8, "start_col": 20, "start_line": 8 }
Steel.ST.Effect.Atomic.STAtomic
val atomic_write (#opened:_) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) (v1:a) : STAtomic unit opened (pts_to r v0) (fun _ -> pts_to r v1) (requires frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ -> True)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let atomic_write r v0 v1 = C.coerce_atomic (fun _ -> P.atomic_write r v0 v1)
val atomic_write (#opened:_) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) (v1:a) : STAtomic unit opened (pts_to r v0) (fun _ -> pts_to r v1) (requires frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ -> True) let atomic_write r v0 v1 =
true
null
false
C.coerce_atomic (fun _ -> P.atomic_write r v0 v1)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.ST.Coercions.coerce_atomic", "Prims.unit", "Steel.Effect.Common.Observable", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.vprop", "Prims.l_and", "FStar.PCM.frame_preserving", "FStar.PCM.__proj__Mkpcm__item__refine", "Prims.l_True", "Steel.PCMReference.atomic_write" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x) let free r x = C.coerce_steel (fun _ -> P.free r x) let split r v v0 v1 = C.coerce_ghost (fun _ -> P.split r v v0 v1) let gather r v0 v1 = C.coerce_ghost (fun _ -> P.gather r v0 v1) let witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) () : Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) = P.witness r fact v () let witness r fact v vc = C.coerce_atomic (witness' r fact v vc) let recall fact r v w = C.coerce_atomic (fun _ -> P.recall fact r v w) let select_refine r x f = C.coerce_steel (fun _ -> P.select_refine r x f) let upd_gen r x y f = C.coerce_steel (fun _ -> P.upd_gen r x y f) let atomic_read r v0 = C.coerce_atomic (fun _ -> P.atomic_read r v0)
false
false
Steel.ST.PCMReference.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 atomic_write (#opened:_) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) (v1:a) : STAtomic unit opened (pts_to r v0) (fun _ -> pts_to r v1) (requires frame_preserving pcm v0 v1 /\ pcm.refine v1) (ensures fun _ -> True)
[]
Steel.ST.PCMReference.atomic_write
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a pcm -> v0: FStar.Ghost.erased a -> v1: a -> Steel.ST.Effect.Atomic.STAtomic Prims.unit
{ "end_col": 76, "end_line": 38, "start_col": 27, "start_line": 38 }
Steel.ST.Effect.STT
val upd_gen (#a:Type) (#p:pcm a) (r:ref a p) (x y:erased a) (f:frame_preserving_upd p x y) : STT unit (pts_to r x) (fun _ -> pts_to r y)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let upd_gen r x y f = C.coerce_steel (fun _ -> P.upd_gen r x y f)
val upd_gen (#a:Type) (#p:pcm a) (r:ref a p) (x y:erased a) (f:frame_preserving_upd p x y) : STT unit (pts_to r x) (fun _ -> pts_to r y) let upd_gen r x y f =
true
null
false
C.coerce_steel (fun _ -> P.upd_gen r x y f)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "FStar.PCM.frame_preserving_upd", "FStar.Ghost.reveal", "Steel.ST.Coercions.coerce_steel", "Prims.unit", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "Steel.Effect.Common.vprop", "Prims.l_True", "Steel.PCMReference.upd_gen" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x) let free r x = C.coerce_steel (fun _ -> P.free r x) let split r v v0 v1 = C.coerce_ghost (fun _ -> P.split r v v0 v1) let gather r v0 v1 = C.coerce_ghost (fun _ -> P.gather r v0 v1) let witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) () : Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) = P.witness r fact v () let witness r fact v vc = C.coerce_atomic (witness' r fact v vc) let recall fact r v w = C.coerce_atomic (fun _ -> P.recall fact r v w) let select_refine r x f = C.coerce_steel (fun _ -> P.select_refine r x f)
false
false
Steel.ST.PCMReference.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_gen (#a:Type) (#p:pcm a) (r:ref a p) (x y:erased a) (f:frame_preserving_upd p x y) : STT unit (pts_to r x) (fun _ -> pts_to r y)
[]
Steel.ST.PCMReference.upd_gen
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a p -> x: FStar.Ghost.erased a -> y: FStar.Ghost.erased a -> f: FStar.PCM.frame_preserving_upd p (FStar.Ghost.reveal x) (FStar.Ghost.reveal y) -> Steel.ST.Effect.STT Prims.unit
{ "end_col": 65, "end_line": 34, "start_col": 22, "start_line": 34 }
Steel.ST.Effect.Atomic.STAtomic
val atomic_read (#opened:_) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) : STAtomic a opened (pts_to r v0) (fun _ -> pts_to r v0) (requires True) (ensures fun v -> compatible pcm v0 v /\ True)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let atomic_read r v0 = C.coerce_atomic (fun _ -> P.atomic_read r v0)
val atomic_read (#opened:_) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) : STAtomic a opened (pts_to r v0) (fun _ -> pts_to r v0) (requires True) (ensures fun v -> compatible pcm v0 v /\ True) let atomic_read r v0 =
true
null
false
C.coerce_atomic (fun _ -> P.atomic_read r v0)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.ST.Coercions.coerce_atomic", "Steel.Effect.Common.Observable", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.vprop", "Prims.l_True", "Prims.l_and", "FStar.PCM.compatible", "Prims.unit", "Steel.PCMReference.atomic_read" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x) let free r x = C.coerce_steel (fun _ -> P.free r x) let split r v v0 v1 = C.coerce_ghost (fun _ -> P.split r v v0 v1) let gather r v0 v1 = C.coerce_ghost (fun _ -> P.gather r v0 v1) let witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) () : Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) = P.witness r fact v () let witness r fact v vc = C.coerce_atomic (witness' r fact v vc) let recall fact r v w = C.coerce_atomic (fun _ -> P.recall fact r v w) let select_refine r x f = C.coerce_steel (fun _ -> P.select_refine r x f) let upd_gen r x y f = C.coerce_steel (fun _ -> P.upd_gen r x y f)
false
false
Steel.ST.PCMReference.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 atomic_read (#opened:_) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) : STAtomic a opened (pts_to r v0) (fun _ -> pts_to r v0) (requires True) (ensures fun v -> compatible pcm v0 v /\ True)
[]
Steel.ST.PCMReference.atomic_read
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a pcm -> v0: FStar.Ghost.erased a -> Steel.ST.Effect.Atomic.STAtomic a
{ "end_col": 68, "end_line": 36, "start_col": 23, "start_line": 36 }
Steel.ST.Effect.ST
val free (#a:Type) (#p:pcm a) (r:ref a p) (x:erased a) : ST unit (pts_to r x) (fun _ -> pts_to r p.p.one) (requires exclusive p x /\ p.refine p.p.one) (ensures fun _ -> True)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let free r x = C.coerce_steel (fun _ -> P.free r x)
val free (#a:Type) (#p:pcm a) (r:ref a p) (x:erased a) : ST unit (pts_to r x) (fun _ -> pts_to r p.p.one) (requires exclusive p x /\ p.refine p.p.one) (ensures fun _ -> True) let free r x =
true
null
false
C.coerce_steel (fun _ -> P.free r x)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.ST.Coercions.coerce_steel", "Prims.unit", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "FStar.Ghost.reveal", "FStar.PCM.__proj__Mkpcm'__item__one", "FStar.PCM.__proj__Mkpcm__item__p", "Steel.Effect.Common.vprop", "Prims.l_and", "FStar.PCM.exclusive", "FStar.PCM.__proj__Mkpcm__item__refine", "Prims.l_True", "Steel.PCMReference.free" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x)
false
false
Steel.ST.PCMReference.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 free (#a:Type) (#p:pcm a) (r:ref a p) (x:erased a) : ST unit (pts_to r x) (fun _ -> pts_to r p.p.one) (requires exclusive p x /\ p.refine p.p.one) (ensures fun _ -> True)
[]
Steel.ST.PCMReference.free
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a p -> x: FStar.Ghost.erased a -> Steel.ST.Effect.ST Prims.unit
{ "end_col": 51, "end_line": 12, "start_col": 15, "start_line": 12 }
Steel.ST.Effect.ST
val read (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) : ST a (pts_to r v0) (fun _ -> pts_to r v0) (requires True) (ensures fun v -> compatible pcm v0 v /\ True)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let read r v0 = C.coerce_steel (fun _ -> P.read r v0)
val read (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) : ST a (pts_to r v0) (fun _ -> pts_to r v0) (requires True) (ensures fun v -> compatible pcm v0 v /\ True) let read r v0 =
true
null
false
C.coerce_steel (fun _ -> P.read r v0)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.ST.Coercions.coerce_steel", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.vprop", "Prims.l_True", "Prims.l_and", "FStar.PCM.compatible", "Prims.unit", "Steel.PCMReference.read" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference
false
false
Steel.ST.PCMReference.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 read (#a:Type) (#pcm:pcm a) (r:ref a pcm) (v0:erased a) : ST a (pts_to r v0) (fun _ -> pts_to r v0) (requires True) (ensures fun v -> compatible pcm v0 v /\ True)
[]
Steel.ST.PCMReference.read
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a pcm -> v0: FStar.Ghost.erased a -> Steel.ST.Effect.ST a
{ "end_col": 53, "end_line": 6, "start_col": 16, "start_line": 6 }
Steel.ST.Effect.Atomic.STAtomicUT
val witness (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) : STAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let witness r fact v vc = C.coerce_atomic (witness' r fact v vc)
val witness (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) : STAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) let witness r fact v vc =
true
null
false
C.coerce_atomic (witness' r fact v vc)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.ref", "Steel.Memory.stable_property", "FStar.Ghost.erased", "Steel.ST.PCMReference.fact_valid_compat", "Steel.ST.Coercions.coerce_atomic", "Steel.Memory.witnessed", "Steel.Effect.Common.Unobservable", "Steel.ST.PCMReference.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.vprop", "Prims.l_True", "Steel.ST.PCMReference.witness'" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x) let free r x = C.coerce_steel (fun _ -> P.free r x) let split r v v0 v1 = C.coerce_ghost (fun _ -> P.split r v v0 v1) let gather r v0 v1 = C.coerce_ghost (fun _ -> P.gather r v0 v1) let witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) () : Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) = P.witness r fact v ()
false
false
Steel.ST.PCMReference.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 witness (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) : STAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v)
[]
Steel.ST.PCMReference.witness
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a pcm -> fact: Steel.Memory.stable_property pcm -> v: FStar.Ghost.erased a -> vc: Steel.ST.PCMReference.fact_valid_compat fact v -> Steel.ST.Effect.Atomic.STAtomicUT (Steel.Memory.witnessed r fact)
{ "end_col": 64, "end_line": 28, "start_col": 26, "start_line": 28 }
Steel.ST.Effect.Atomic.STAtomicU
val recall (#inames: _) (#a:Type u#1) (#pcm:pcm a) (fact:property a) (r:ref a pcm) (v:erased a) (w:witnessed r fact) : STAtomicU (erased a) inames (pts_to r v) (fun v1 -> pts_to r v) (requires True) (ensures fun v1 -> fact v1 /\ compatible pcm v v1)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let recall fact r v w = C.coerce_atomic (fun _ -> P.recall fact r v w)
val recall (#inames: _) (#a:Type u#1) (#pcm:pcm a) (fact:property a) (r:ref a pcm) (v:erased a) (w:witnessed r fact) : STAtomicU (erased a) inames (pts_to r v) (fun v1 -> pts_to r v) (requires True) (ensures fun v1 -> fact v1 /\ compatible pcm v v1) let recall fact r v w =
true
null
false
C.coerce_atomic (fun _ -> P.recall fact r v w)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.property", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.Memory.witnessed", "Steel.ST.Coercions.coerce_atomic", "Steel.Effect.Common.Unobservable", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "FStar.Ghost.reveal", "FStar.Ghost.hide", "Steel.Effect.Common.vprop", "Prims.l_True", "Prims.l_and", "FStar.PCM.compatible", "Prims.unit", "Steel.PCMReference.recall" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x) let free r x = C.coerce_steel (fun _ -> P.free r x) let split r v v0 v1 = C.coerce_ghost (fun _ -> P.split r v v0 v1) let gather r v0 v1 = C.coerce_ghost (fun _ -> P.gather r v0 v1) let witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) () : Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) = P.witness r fact v () let witness r fact v vc = C.coerce_atomic (witness' r fact v vc)
false
false
Steel.ST.PCMReference.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 recall (#inames: _) (#a:Type u#1) (#pcm:pcm a) (fact:property a) (r:ref a pcm) (v:erased a) (w:witnessed r fact) : STAtomicU (erased a) inames (pts_to r v) (fun v1 -> pts_to r v) (requires True) (ensures fun v1 -> fact v1 /\ compatible pcm v v1)
[]
Steel.ST.PCMReference.recall
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
fact: Steel.Memory.property a -> r: Steel.Memory.ref a pcm -> v: FStar.Ghost.erased a -> w: Steel.Memory.witnessed r fact -> Steel.ST.Effect.Atomic.STAtomicU (FStar.Ghost.erased a)
{ "end_col": 70, "end_line": 30, "start_col": 24, "start_line": 30 }
Steel.ST.Effect.STT
val select_refine (#a:Type u#1) (#p:pcm a) (r:ref a p) (x:erased a) (f:(v:a{compatible p x v} -> GTot (y:a{compatible p y v /\ frame_compatible p x v y}))) : STT (v:a{compatible p x v /\ p.refine v}) (pts_to r x) (fun v -> pts_to r (f v))
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let select_refine r x f = C.coerce_steel (fun _ -> P.select_refine r x f)
val select_refine (#a:Type u#1) (#p:pcm a) (r:ref a p) (x:erased a) (f:(v:a{compatible p x v} -> GTot (y:a{compatible p y v /\ frame_compatible p x v y}))) : STT (v:a{compatible p x v /\ p.refine v}) (pts_to r x) (fun v -> pts_to r (f v)) let select_refine r x f =
true
null
false
C.coerce_steel (fun _ -> P.select_refine r x f)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "FStar.PCM.compatible", "FStar.Ghost.reveal", "Prims.l_and", "FStar.PCM.frame_compatible", "Steel.ST.Coercions.coerce_steel", "FStar.PCM.__proj__Mkpcm__item__refine", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "Steel.Effect.Common.vprop", "Prims.l_True", "Prims.unit", "Steel.PCMReference.select_refine" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x) let free r x = C.coerce_steel (fun _ -> P.free r x) let split r v v0 v1 = C.coerce_ghost (fun _ -> P.split r v v0 v1) let gather r v0 v1 = C.coerce_ghost (fun _ -> P.gather r v0 v1) let witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) () : Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) = P.witness r fact v () let witness r fact v vc = C.coerce_atomic (witness' r fact v vc) let recall fact r v w = C.coerce_atomic (fun _ -> P.recall fact r v w)
false
false
Steel.ST.PCMReference.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 select_refine (#a:Type u#1) (#p:pcm a) (r:ref a p) (x:erased a) (f:(v:a{compatible p x v} -> GTot (y:a{compatible p y v /\ frame_compatible p x v y}))) : STT (v:a{compatible p x v /\ p.refine v}) (pts_to r x) (fun v -> pts_to r (f v))
[]
Steel.ST.PCMReference.select_refine
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a p -> x: FStar.Ghost.erased a -> f: (v: a{FStar.PCM.compatible p (FStar.Ghost.reveal x) v} -> Prims.GTot (y: a{FStar.PCM.compatible p y v /\ FStar.PCM.frame_compatible p x v y})) -> Steel.ST.Effect.STT (v: a{FStar.PCM.compatible p (FStar.Ghost.reveal x) v /\ Mkpcm?.refine p v})
{ "end_col": 73, "end_line": 32, "start_col": 26, "start_line": 32 }
Steel.ST.Effect.Ghost.STGhost
val split (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v:erased a) (v0:erased a) (v1:erased a) : STGhost unit inames (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires composable p v0 v1 /\ v == hide (op p v0 v1)) (ensures fun _ -> True)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let split r v v0 v1 = C.coerce_ghost (fun _ -> P.split r v v0 v1)
val split (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v:erased a) (v0:erased a) (v1:erased a) : STGhost unit inames (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires composable p v0 v1 /\ v == hide (op p v0 v1)) (ensures fun _ -> True) let split r v v0 v1 =
true
null
false
C.coerce_ghost (fun _ -> P.split r v v0 v1)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.ST.Coercions.coerce_ghost", "Prims.unit", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "FStar.Ghost.reveal", "Steel.Effect.Common.star", "Steel.Effect.Common.vprop", "Prims.l_and", "FStar.PCM.composable", "Prims.eq2", "FStar.Ghost.hide", "FStar.PCM.op", "Prims.l_True", "Steel.PCMReference.split" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x) let free r x = C.coerce_steel (fun _ -> P.free r x)
false
false
Steel.ST.PCMReference.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 split (#inames: _) (#a:Type) (#p:pcm a) (r:ref a p) (v:erased a) (v0:erased a) (v1:erased a) : STGhost unit inames (pts_to r v) (fun _ -> pts_to r v0 `star` pts_to r v1) (requires composable p v0 v1 /\ v == hide (op p v0 v1)) (ensures fun _ -> True)
[]
Steel.ST.PCMReference.split
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a p -> v: FStar.Ghost.erased a -> v0: FStar.Ghost.erased a -> v1: FStar.Ghost.erased a -> Steel.ST.Effect.Ghost.STGhost Prims.unit
{ "end_col": 65, "end_line": 14, "start_col": 22, "start_line": 14 }
Steel.Effect.Atomic.SteelAtomicUT
val witness': #inames: _ -> #a: Type -> #pcm: pcm a -> r: ref a pcm -> fact: stable_property pcm -> v: erased a -> fact_valid_compat fact v -> Prims.unit -> Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v)
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) () : Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) = P.witness r fact v ()
val witness': #inames: _ -> #a: Type -> #pcm: pcm a -> r: ref a pcm -> fact: stable_property pcm -> v: erased a -> fact_valid_compat fact v -> Prims.unit -> Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) let witness' (#inames: _) (#a: Type) (#pcm: pcm a) (r: ref a pcm) (fact: stable_property pcm) (v: erased a) (_: fact_valid_compat fact v) () : Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v) =
true
null
false
P.witness r fact v ()
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.ref", "Steel.Memory.stable_property", "FStar.Ghost.erased", "Steel.ST.PCMReference.fact_valid_compat", "Prims.unit", "Steel.PCMReference.witness", "FStar.Ghost.hide", "Steel.Memory.witnessed", "FStar.Ghost.reveal", "Steel.ST.PCMReference.pts_to", "Steel.Effect.Common.vprop" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x) let free r x = C.coerce_steel (fun _ -> P.free r x) let split r v v0 v1 = C.coerce_ghost (fun _ -> P.split r v v0 v1) let gather r v0 v1 = C.coerce_ghost (fun _ -> P.gather r v0 v1) let witness' (#inames: _) (#a:Type) (#pcm:pcm a) (r:ref a pcm) (fact:stable_property pcm) (v:erased a) (_:fact_valid_compat fact v) () : Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v)
false
false
Steel.ST.PCMReference.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 witness': #inames: _ -> #a: Type -> #pcm: pcm a -> r: ref a pcm -> fact: stable_property pcm -> v: erased a -> fact_valid_compat fact v -> Prims.unit -> Steel.Effect.Atomic.SteelAtomicUT (witnessed r fact) inames (pts_to r v) (fun _ -> pts_to r v)
[]
Steel.ST.PCMReference.witness'
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a pcm -> fact: Steel.Memory.stable_property pcm -> v: FStar.Ghost.erased a -> _: Steel.ST.PCMReference.fact_valid_compat fact v -> _: Prims.unit -> Steel.Effect.Atomic.SteelAtomicUT (Steel.Memory.witnessed r fact)
{ "end_col": 23, "end_line": 26, "start_col": 2, "start_line": 26 }
Steel.ST.Effect.Ghost.STGhostT
val gather (#inames: _) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:erased a) (v1:erased a) : STGhostT (_:unit{composable p v0 v1}) inames (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1))
[ { "abbrev": true, "full_module": "Steel.PCMReference", "short_module": "P" }, { "abbrev": true, "full_module": "Steel.ST.Coercions", "short_module": "C" }, { "abbrev": false, "full_module": "Steel.ST.Util", "short_module": null }, { "abbrev": false, "full_module": "FStar.Ghost", "short_module": null }, { "abbrev": false, "full_module": "FStar.PCM", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "Steel.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gather r v0 v1 = C.coerce_ghost (fun _ -> P.gather r v0 v1)
val gather (#inames: _) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:erased a) (v1:erased a) : STGhostT (_:unit{composable p v0 v1}) inames (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1)) let gather r v0 v1 =
true
null
false
C.coerce_ghost (fun _ -> P.gather r v0 v1)
{ "checked_file": "Steel.ST.PCMReference.fst.checked", "dependencies": [ "Steel.ST.Coercions.fsti.checked", "Steel.PCMReference.fsti.checked", "Steel.Effect.Atomic.fsti.checked", "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.ST.PCMReference.fst" }
[]
[ "Steel.Memory.inames", "FStar.PCM.pcm", "Steel.Memory.ref", "FStar.Ghost.erased", "Steel.ST.Coercions.coerce_ghost", "Prims.unit", "FStar.PCM.composable", "FStar.Ghost.reveal", "Steel.Effect.Common.star", "Steel.Effect.Common.VUnit", "Steel.Effect.Common.to_vprop'", "Steel.Memory.pts_to", "FStar.PCM.op", "Steel.Effect.Common.vprop", "Prims.l_True", "Steel.PCMReference.gather" ]
[]
module Steel.ST.PCMReference module C = Steel.ST.Coercions module P = Steel.PCMReference let read r v0 = C.coerce_steel (fun _ -> P.read r v0) let write r v0 v1 = C.coerce_steel (fun _ -> P.write r v0 v1) let alloc x = C.coerce_steel (fun _ -> P.alloc x) let free r x = C.coerce_steel (fun _ -> P.free r x) let split r v v0 v1 = C.coerce_ghost (fun _ -> P.split r v v0 v1)
false
false
Steel.ST.PCMReference.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 gather (#inames: _) (#a:Type) (#p:FStar.PCM.pcm a) (r:ref a p) (v0:erased a) (v1:erased a) : STGhostT (_:unit{composable p v0 v1}) inames (pts_to r v0 `star` pts_to r v1) (fun _ -> pts_to r (op p v0 v1))
[]
Steel.ST.PCMReference.gather
{ "file_name": "lib/steel/Steel.ST.PCMReference.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
r: Steel.Memory.ref a p -> v0: FStar.Ghost.erased a -> v1: FStar.Ghost.erased a -> Steel.ST.Effect.Ghost.STGhostT (_: Prims.unit{FStar.PCM.composable p (FStar.Ghost.reveal v0) (FStar.Ghost.reveal v1)})
{ "end_col": 63, "end_line": 16, "start_col": 21, "start_line": 16 }
Prims.GTot
val length (#a:Type0) (x:t a) : GTot nat
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let length x = L.length x
val length (#a:Type0) (x:t a) : GTot nat let length x =
false
null
false
L.length x
{ "checked_file": "Steel.TLArray.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.TLArray.fst" }
[ "sometrivial" ]
[ "Steel.TLArray.t", "FStar.List.Tot.Base.length", "Prims.nat" ]
[]
module Steel.TLArray let t a = list a
false
false
Steel.TLArray.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 length (#a:Type0) (x:t a) : GTot nat
[]
Steel.TLArray.length
{ "file_name": "lib/steel/Steel.TLArray.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
x: Steel.TLArray.t a -> Prims.GTot Prims.nat
{ "end_col": 25, "end_line": 6, "start_col": 15, "start_line": 6 }
Prims.Tot
val t (a:Type0) : Type0
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let t a = list a
val t (a:Type0) : Type0 let t a =
false
null
false
list a
{ "checked_file": "Steel.TLArray.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.TLArray.fst" }
[ "total" ]
[ "Prims.list" ]
[]
module Steel.TLArray
false
true
Steel.TLArray.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 t (a:Type0) : Type0
[]
Steel.TLArray.t
{ "file_name": "lib/steel/Steel.TLArray.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
a: Type0 -> Type0
{ "end_col": 16, "end_line": 3, "start_col": 10, "start_line": 3 }
Prims.Tot
val v (#a:Type0) (x : t a) : G.erased (list a)
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let v x = G.hide x
val v (#a:Type0) (x : t a) : G.erased (list a) let v x =
false
null
false
G.hide x
{ "checked_file": "Steel.TLArray.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.TLArray.fst" }
[ "total" ]
[ "Steel.TLArray.t", "FStar.Ghost.hide", "Prims.list", "FStar.Ghost.erased" ]
[]
module Steel.TLArray let t a = list a
false
false
Steel.TLArray.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 v (#a:Type0) (x : t a) : G.erased (list a)
[]
Steel.TLArray.v
{ "file_name": "lib/steel/Steel.TLArray.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
x: Steel.TLArray.t a -> FStar.Ghost.erased (Prims.list a)
{ "end_col": 18, "end_line": 5, "start_col": 10, "start_line": 5 }
Prims.Pure
val create (#a:Type0) (l: list a) : Pure (t a) (requires True) (ensures fun x -> Ghost.reveal (v x) == l /\ length x == normalize_term (List.Tot.length l))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let create l = l
val create (#a:Type0) (l: list a) : Pure (t a) (requires True) (ensures fun x -> Ghost.reveal (v x) == l /\ length x == normalize_term (List.Tot.length l)) let create l =
false
null
false
l
{ "checked_file": "Steel.TLArray.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.TLArray.fst" }
[]
[ "Prims.list", "Steel.TLArray.t" ]
[]
module Steel.TLArray let t a = list a let v x = G.hide x let length x = L.length x
false
false
Steel.TLArray.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 create (#a:Type0) (l: list a) : Pure (t a) (requires True) (ensures fun x -> Ghost.reveal (v x) == l /\ length x == normalize_term (List.Tot.length l))
[]
Steel.TLArray.create
{ "file_name": "lib/steel/Steel.TLArray.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
l: Prims.list a -> Prims.Pure (Steel.TLArray.t a)
{ "end_col": 16, "end_line": 8, "start_col": 15, "start_line": 8 }
Prims.Pure
val get (#a:Type0) (x: t a) (i:U32.t{U32.v i < length x}) : Pure a (requires True) (ensures fun y -> U32.v i < L.length (v x) /\ y == L.index (v x) (U32.v i))
[ { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": true, "full_module": "FStar.Ghost", "short_module": "G" }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_module": "Steel", "short_module": null }, { "abbrev": false, "full_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 x i = L.index x (U32.v i)
val get (#a:Type0) (x: t a) (i:U32.t{U32.v i < length x}) : Pure a (requires True) (ensures fun y -> U32.v i < L.length (v x) /\ y == L.index (v x) (U32.v i)) let get x i =
false
null
false
L.index x (U32.v i)
{ "checked_file": "Steel.TLArray.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Steel.TLArray.fst" }
[]
[ "Steel.TLArray.t", "FStar.UInt32.t", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt32.v", "Steel.TLArray.length", "FStar.List.Tot.Base.index" ]
[]
module Steel.TLArray let t a = list a let v x = G.hide x let length x = L.length x
false
false
Steel.TLArray.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 get (#a:Type0) (x: t a) (i:U32.t{U32.v i < length x}) : Pure a (requires True) (ensures fun y -> U32.v i < L.length (v x) /\ y == L.index (v x) (U32.v i))
[]
Steel.TLArray.get
{ "file_name": "lib/steel/Steel.TLArray.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
x: Steel.TLArray.t a -> i: FStar.UInt32.t{FStar.UInt32.v i < Steel.TLArray.length x} -> Prims.Pure a
{ "end_col": 33, "end_line": 9, "start_col": 14, "start_line": 9 }
FStar.Tactics.Effect.Tac
val check (g:env) (pre:term) (pre_typing: tot_typing g pre tm_vprop) (post_hint:post_hint_for_env g) (res_ppname:ppname) (b:term) (e1 e2:st_term) (check:check_t) : T.Tac (checker_result_t g pre (Some post_hint))
[ { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let check (g:env) (pre:term) (pre_typing: tot_typing g pre tm_vprop) (post_hint:post_hint_for_env g) (res_ppname:ppname) (b:term) (e1 e2:st_term) (check:check_t) : T.Tac (checker_result_t g pre (Some post_hint)) = let g = Pulse.Typing.Env.push_context g "check_if" e1.range in let (| b, b_typing |) = check_tot_term_with_expected_type g b tm_bool in let post = post_hint.post in let hyp = fresh g in let g_with_eq (eq_v:term) = push_binding g hyp (mk_ppname_no_range "_if_hyp") (mk_eq2 u0 tm_bool b eq_v) in let check_branch (eq_v:term) (br:st_term) (is_then:bool) : T.Tac (br:st_term { ~(hyp `Set.mem` freevars_st br) } & c:comp_st { comp_pre c == pre /\ comp_post_matches_hint c (Some post_hint)} & st_typing (g_with_eq eq_v) br c) = let g_with_eq = g_with_eq eq_v in let pre_typing = Metatheory.tot_typing_weakening_single pre_typing hyp (mk_eq2 u0 tm_bool b eq_v) in let (| br, c, d |) = let ppname = mk_ppname_no_range "_if_br" in let r = check g_with_eq pre pre_typing (Some post_hint) ppname br in apply_checker_result_k r ppname in let br_name = if is_then then "then" else "else" in if hyp `Set.mem` freevars_st br then fail g (Some br.range) (Printf.sprintf "check_if: branch hypothesis is in freevars of checked %s branch" br_name) else (| br, c, d |) in let (| e1, c1, e1_typing |) = check_branch tm_true e1 true in let (| e2, c2, e2_typing |) = check_branch tm_false e2 false in let (| c, e1_typing, e2_typing |) = combine_if_branches _ _ _ e1_typing _ _ _ e2_typing in let c_typing = let x = fresh g in if x `Set.mem` freevars post //exclude this then fail g None "Impossible: check_if: unexpected freevar in post, please file a bug-report" else if not (eq_tm (comp_res c) post_hint.ret_ty && eq_univ (comp_u c) post_hint.u && eq_tm (comp_post c) post_hint.post) //exclude by check' strengthening then fail g None (Printf.sprintf "check_if: computation type after combining branches does not match post hint,\ computed: (%s, %s, %s), expected (%s, %s, %s)" (P.univ_to_string (comp_u c)) (P.term_to_string (comp_res c)) (P.term_to_string (comp_post c)) (P.univ_to_string post_hint.u) (P.term_to_string post_hint.ret_ty) (P.term_to_string post_hint.post)) else let post_typing = post_hint_typing g post_hint x in intro_comp_typing g c pre_typing post_typing.ty_typing x post_typing.post_typing in let d : st_typing_in_ctxt g pre (Some post_hint) = (| _, c, T_If g b e1 e2 c _ hyp b_typing e1_typing e2_typing (E c_typing) |) in checker_result_for_st_typing d res_ppname
val check (g:env) (pre:term) (pre_typing: tot_typing g pre tm_vprop) (post_hint:post_hint_for_env g) (res_ppname:ppname) (b:term) (e1 e2:st_term) (check:check_t) : T.Tac (checker_result_t g pre (Some post_hint)) let check (g: env) (pre: term) (pre_typing: tot_typing g pre tm_vprop) (post_hint: post_hint_for_env g) (res_ppname: ppname) (b: term) (e1 e2: st_term) (check: check_t) : T.Tac (checker_result_t g pre (Some post_hint)) =
true
null
false
let g = Pulse.Typing.Env.push_context g "check_if" e1.range in let (| b , b_typing |) = check_tot_term_with_expected_type g b tm_bool in let post = post_hint.post in let hyp = fresh g in let g_with_eq (eq_v: term) = push_binding g hyp (mk_ppname_no_range "_if_hyp") (mk_eq2 u0 tm_bool b eq_v) in let check_branch (eq_v: term) (br: st_term) (is_then: bool) : T.Tac (br: st_term{~(hyp `Set.mem` (freevars_st br))} & c: comp_st{comp_pre c == pre /\ comp_post_matches_hint c (Some post_hint)} & st_typing (g_with_eq eq_v) br c) = let g_with_eq = g_with_eq eq_v in let pre_typing = Metatheory.tot_typing_weakening_single pre_typing hyp (mk_eq2 u0 tm_bool b eq_v) in let (| br , c , d |) = let ppname = mk_ppname_no_range "_if_br" in let r = check g_with_eq pre pre_typing (Some post_hint) ppname br in apply_checker_result_k r ppname in let br_name = if is_then then "then" else "else" in if hyp `Set.mem` (freevars_st br) then fail g (Some br.range) (Printf.sprintf "check_if: branch hypothesis is in freevars of checked %s branch" br_name) else (| br, c, d |) in let (| e1 , c1 , e1_typing |) = check_branch tm_true e1 true in let (| e2 , c2 , e2_typing |) = check_branch tm_false e2 false in let (| c , e1_typing , e2_typing |) = combine_if_branches _ _ _ e1_typing _ _ _ e2_typing in let c_typing = let x = fresh g in if x `Set.mem` (freevars post) then fail g None "Impossible: check_if: unexpected freevar in post, please file a bug-report" else if not (eq_tm (comp_res c) post_hint.ret_ty && eq_univ (comp_u c) post_hint.u && eq_tm (comp_post c) post_hint.post) then fail g None (Printf.sprintf "check_if: computation type after combining branches does not match post hint,computed: (%s, %s, %s), expected (%s, %s, %s)" (P.univ_to_string (comp_u c)) (P.term_to_string (comp_res c)) (P.term_to_string (comp_post c)) (P.univ_to_string post_hint.u) (P.term_to_string post_hint.ret_ty) (P.term_to_string post_hint.post)) else let post_typing = post_hint_typing g post_hint x in intro_comp_typing g c pre_typing post_typing.ty_typing x post_typing.post_typing in let d:st_typing_in_ctxt g pre (Some post_hint) = (| _, c, T_If g b e1 e2 c _ hyp b_typing e1_typing e2_typing (E c_typing) |) in checker_result_for_st_typing d res_ppname
{ "checked_file": "Pulse.Checker.If.fst.checked", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.If.fst" }
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.term", "Pulse.Typing.tot_typing", "Pulse.Syntax.Base.tm_vprop", "Pulse.Typing.post_hint_for_env", "Pulse.Syntax.Base.ppname", "Pulse.Syntax.Base.st_term", "Pulse.Checker.Base.check_t", "Pulse.Typing.tm_bool", "Prims.l_not", "Prims.b2t", "FStar.Set.mem", "Pulse.Syntax.Base.var", "Pulse.Syntax.Naming.freevars_st", "Pulse.Syntax.Base.comp_st", "Prims.l_and", "Prims.eq2", "Pulse.Syntax.Base.comp_pre", "Pulse.Typing.comp_post_matches_hint", "FStar.Pervasives.Native.Some", "Pulse.Typing.post_hint_t", "Pulse.Typing.st_typing", "Pulse.Typing.tm_true", "Pulse.Typing.tm_false", "Pulse.Syntax.Base.st_comp", "Pulse.Syntax.Base.st_comp_of_comp", "Pulse.Checker.Base.checker_result_for_st_typing", "Pulse.Checker.Base.checker_result_t", "Pulse.Typing.Combinators.st_typing_in_ctxt", "FStar.Pervasives.Mkdtuple3", "Pulse.Syntax.Base.vprop", "Pulse.Typing.wr", "Pulse.Syntax.Base.Tm_If", "Pulse.Syntax.Base.Mkst_term'__Tm_If__payload", "FStar.Pervasives.Native.None", "Pulse.Typing.T_If", "Pulse.Syntax.Base.comp_u", "Pulse.Typing.E", "Pulse.Typing.comp_typing", "Pulse.Syntax.Naming.freevars", "Pulse.Typing.Env.fail", "Pulse.Syntax.Base.range", "Prims.bool", "Prims.op_Negation", "Prims.op_AmpAmp", "Pulse.Syntax.Base.eq_tm", "Pulse.Syntax.Base.comp_res", "Pulse.Typing.__proj__Mkpost_hint_t__item__ret_ty", "Pulse.Syntax.Base.eq_univ", "Pulse.Typing.__proj__Mkpost_hint_t__item__u", "Pulse.Syntax.Base.comp_post", "Pulse.Typing.__proj__Mkpost_hint_t__item__post", "Prims.string", "Pulse.Syntax.Printer.univ_to_string", "FStar.Printf.sprintf", "Pulse.Syntax.Printer.term_to_string", "Pulse.Checker.Base.intro_comp_typing", "Pulse.Typing.__proj__Mkpost_hint_typing_t__item__ty_typing", "Pulse.Typing.__proj__Mkpost_hint_typing_t__item__post_typing", "Pulse.Typing.post_hint_typing_t", "Pulse.Typing.post_hint_typing", "Pulse.Typing.Env.dom", "Pulse.Typing.Env.fresh", "FStar.Pervasives.dtuple3", "Pulse.Checker.If.combine_if_branches", "Pulse.Syntax.Base.__proj__Mkst_term__item__range", "Pulse.Checker.Base.apply_checker_result_k", "Pulse.Syntax.Base.mk_ppname_no_range", "Pulse.Typing.Env.push_binding", "Pulse.Syntax.Base.ppname_default", "Pulse.Typing.mk_eq2", "Pulse.Syntax.Pure.u0", "Pulse.Typing.Metatheory.tot_typing_weakening_single", "FStar.Reflection.Typing.fstar_top_env", "Pulse.Typing.Env.fstar_env", "Prims.dtuple2", "Pulse.Checker.Pure.check_tot_term_with_expected_type", "Pulse.Typing.Env.push_context" ]
[]
module Pulse.Checker.If open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory #push-options "--z3rlimit_factor 16 --fuel 0 --ifuel 1" let rec combine_if_branches (g_then:env) (e_then:st_term) (c_then:comp_st) (e_then_typing:st_typing g_then e_then c_then) (g_else:env) (e_else:st_term) (c_else:comp_st) (e_else_typing:st_typing g_else e_else c_else) : T.TacH (c:comp_st{st_comp_of_comp c == st_comp_of_comp c_then} & st_typing g_then e_then c & st_typing g_else e_else c) (requires fun _ -> comp_pre c_then == comp_pre c_else) (ensures fun _ _ -> True) = let g = g_then in if eq_st_comp (st_comp_of_comp c_then) (st_comp_of_comp c_else) then begin match c_then, c_else with | C_ST _, C_ST _ -> (| c_then, e_then_typing, e_else_typing |) | C_STAtomic inames1 _, C_STAtomic inames2 _ | C_STGhost inames1 _, C_STGhost inames2 _ -> if eq_tm inames1 inames2 then (| c_then, e_then_typing, e_else_typing |) else fail g None (Printf.sprintf "Cannot combine then and else branches (different inames %s and %s)" (P.term_to_string inames1) (P.term_to_string inames2)) | C_ST _, C_STAtomic inames _ -> if eq_tm inames tm_emp_inames then begin let e_else_typing = T_Lift g_else e_else c_else c_then e_else_typing (Lift_STAtomic_ST g_else c_else) in (| c_then, e_then_typing, e_else_typing |) end else fail g None (Printf.sprintf "Cannot lift STAtomic else branch to match ST then branch, inames %s not empty" (P.term_to_string inames)) | C_STAtomic inames _, C_ST _ -> if eq_tm inames tm_emp_inames then begin let e_then_typing = T_Lift g_then e_then c_then c_else e_then_typing (Lift_STAtomic_ST g_then c_then) in (| c_else, e_then_typing, e_else_typing |) end else fail g None (Printf.sprintf "Cannot lift STAtomic then branch to match ST else branch, inames %s not empty" (P.term_to_string inames)) | C_STGhost _ _, _ -> let w = get_non_informative_witness g_then (comp_u c_then) (comp_res c_then) in let e_then_typing = T_Lift _ _ _ _ e_then_typing (Lift_STGhost_STAtomic _ _ w) in let (| c, e1_typing, e2_typing |) = combine_if_branches _ _ _ e_then_typing _ _ _ e_else_typing in (| c, e1_typing, e2_typing |) | _, C_STGhost _ _ -> let w = get_non_informative_witness g_else (comp_u c_else) (comp_res c_else) in let e_else_typing = T_Lift _ _ _ _ e_else_typing (Lift_STGhost_STAtomic _ _ w) in combine_if_branches _ _ _ e_then_typing _ _ _ e_else_typing | _, _ -> fail g None (Printf.sprintf "Cannot combine then and else branches (incompatible effects %s and %s resp.)" (P.ctag_to_string (ctag_of_comp_st c_then)) (P.ctag_to_string (ctag_of_comp_st c_else))) end else fail g None "Cannot combine then and else branches (different st_comp)" #pop-options #push-options "--z3rlimit_factor 4 --fuel 0 --ifuel 1" let check (g:env) (pre:term) (pre_typing: tot_typing g pre tm_vprop) (post_hint:post_hint_for_env g) (res_ppname:ppname) (b:term) (e1 e2:st_term)
false
false
Pulse.Checker.If.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 4, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val check (g:env) (pre:term) (pre_typing: tot_typing g pre tm_vprop) (post_hint:post_hint_for_env g) (res_ppname:ppname) (b:term) (e1 e2:st_term) (check:check_t) : T.Tac (checker_result_t g pre (Some post_hint))
[]
Pulse.Checker.If.check
{ "file_name": "lib/steel/pulse/Pulse.Checker.If.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
g: Pulse.Typing.Env.env -> pre: Pulse.Syntax.Base.term -> pre_typing: Pulse.Typing.tot_typing g pre Pulse.Syntax.Base.tm_vprop -> post_hint: Pulse.Typing.post_hint_for_env g -> res_ppname: Pulse.Syntax.Base.ppname -> b: Pulse.Syntax.Base.term -> e1: Pulse.Syntax.Base.st_term -> e2: Pulse.Syntax.Base.st_term -> check: Pulse.Checker.Base.check_t -> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g pre (FStar.Pervasives.Native.Some post_hint))
{ "end_col": 43, "end_line": 160, "start_col": 53, "start_line": 96 }
FStar.Tactics.Effect.TacH
val combine_if_branches (g_then: env) (e_then: st_term) (c_then: comp_st) (e_then_typing: st_typing g_then e_then c_then) (g_else: env) (e_else: st_term) (c_else: comp_st) (e_else_typing: st_typing g_else e_else c_else) : T.TacH (c: comp_st{st_comp_of_comp c == st_comp_of_comp c_then} & st_typing g_then e_then c & st_typing g_else e_else c) (requires fun _ -> comp_pre c_then == comp_pre c_else) (ensures fun _ _ -> True)
[ { "abbrev": true, "full_module": "Pulse.Typing.Metatheory", "short_module": "Metatheory" }, { "abbrev": true, "full_module": "Pulse.Syntax.Printer", "short_module": "P" }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker.Prover", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Pure", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing.Combinators", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker.Base", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Typing", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Syntax", "short_module": null }, { "abbrev": true, "full_module": "FStar.Tactics.V2", "short_module": "T" }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_module": "Pulse.Checker", "short_module": null }, { "abbrev": false, "full_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 combine_if_branches (g_then:env) (e_then:st_term) (c_then:comp_st) (e_then_typing:st_typing g_then e_then c_then) (g_else:env) (e_else:st_term) (c_else:comp_st) (e_else_typing:st_typing g_else e_else c_else) : T.TacH (c:comp_st{st_comp_of_comp c == st_comp_of_comp c_then} & st_typing g_then e_then c & st_typing g_else e_else c) (requires fun _ -> comp_pre c_then == comp_pre c_else) (ensures fun _ _ -> True) = let g = g_then in if eq_st_comp (st_comp_of_comp c_then) (st_comp_of_comp c_else) then begin match c_then, c_else with | C_ST _, C_ST _ -> (| c_then, e_then_typing, e_else_typing |) | C_STAtomic inames1 _, C_STAtomic inames2 _ | C_STGhost inames1 _, C_STGhost inames2 _ -> if eq_tm inames1 inames2 then (| c_then, e_then_typing, e_else_typing |) else fail g None (Printf.sprintf "Cannot combine then and else branches (different inames %s and %s)" (P.term_to_string inames1) (P.term_to_string inames2)) | C_ST _, C_STAtomic inames _ -> if eq_tm inames tm_emp_inames then begin let e_else_typing = T_Lift g_else e_else c_else c_then e_else_typing (Lift_STAtomic_ST g_else c_else) in (| c_then, e_then_typing, e_else_typing |) end else fail g None (Printf.sprintf "Cannot lift STAtomic else branch to match ST then branch, inames %s not empty" (P.term_to_string inames)) | C_STAtomic inames _, C_ST _ -> if eq_tm inames tm_emp_inames then begin let e_then_typing = T_Lift g_then e_then c_then c_else e_then_typing (Lift_STAtomic_ST g_then c_then) in (| c_else, e_then_typing, e_else_typing |) end else fail g None (Printf.sprintf "Cannot lift STAtomic then branch to match ST else branch, inames %s not empty" (P.term_to_string inames)) | C_STGhost _ _, _ -> let w = get_non_informative_witness g_then (comp_u c_then) (comp_res c_then) in let e_then_typing = T_Lift _ _ _ _ e_then_typing (Lift_STGhost_STAtomic _ _ w) in let (| c, e1_typing, e2_typing |) = combine_if_branches _ _ _ e_then_typing _ _ _ e_else_typing in (| c, e1_typing, e2_typing |) | _, C_STGhost _ _ -> let w = get_non_informative_witness g_else (comp_u c_else) (comp_res c_else) in let e_else_typing = T_Lift _ _ _ _ e_else_typing (Lift_STGhost_STAtomic _ _ w) in combine_if_branches _ _ _ e_then_typing _ _ _ e_else_typing | _, _ -> fail g None (Printf.sprintf "Cannot combine then and else branches (incompatible effects %s and %s resp.)" (P.ctag_to_string (ctag_of_comp_st c_then)) (P.ctag_to_string (ctag_of_comp_st c_else))) end else fail g None "Cannot combine then and else branches (different st_comp)"
val combine_if_branches (g_then: env) (e_then: st_term) (c_then: comp_st) (e_then_typing: st_typing g_then e_then c_then) (g_else: env) (e_else: st_term) (c_else: comp_st) (e_else_typing: st_typing g_else e_else c_else) : T.TacH (c: comp_st{st_comp_of_comp c == st_comp_of_comp c_then} & st_typing g_then e_then c & st_typing g_else e_else c) (requires fun _ -> comp_pre c_then == comp_pre c_else) (ensures fun _ _ -> True) let rec combine_if_branches (g_then: env) (e_then: st_term) (c_then: comp_st) (e_then_typing: st_typing g_then e_then c_then) (g_else: env) (e_else: st_term) (c_else: comp_st) (e_else_typing: st_typing g_else e_else c_else) : T.TacH (c: comp_st{st_comp_of_comp c == st_comp_of_comp c_then} & st_typing g_then e_then c & st_typing g_else e_else c) (requires fun _ -> comp_pre c_then == comp_pre c_else) (ensures fun _ _ -> True) =
false
null
false
let g = g_then in if eq_st_comp (st_comp_of_comp c_then) (st_comp_of_comp c_else) then match c_then, c_else with | C_ST _, C_ST _ -> (| c_then, e_then_typing, e_else_typing |) | C_STAtomic inames1 _, C_STAtomic inames2 _ | C_STGhost inames1 _, C_STGhost inames2 _ -> if eq_tm inames1 inames2 then (| c_then, e_then_typing, e_else_typing |) else fail g None (Printf.sprintf "Cannot combine then and else branches (different inames %s and %s)" (P.term_to_string inames1) (P.term_to_string inames2)) | C_ST _, C_STAtomic inames _ -> if eq_tm inames tm_emp_inames then let e_else_typing = T_Lift g_else e_else c_else c_then e_else_typing (Lift_STAtomic_ST g_else c_else) in (| c_then, e_then_typing, e_else_typing |) else fail g None (Printf.sprintf "Cannot lift STAtomic else branch to match ST then branch, inames %s not empty" (P.term_to_string inames)) | C_STAtomic inames _, C_ST _ -> if eq_tm inames tm_emp_inames then let e_then_typing = T_Lift g_then e_then c_then c_else e_then_typing (Lift_STAtomic_ST g_then c_then) in (| c_else, e_then_typing, e_else_typing |) else fail g None (Printf.sprintf "Cannot lift STAtomic then branch to match ST else branch, inames %s not empty" (P.term_to_string inames)) | C_STGhost _ _, _ -> let w = get_non_informative_witness g_then (comp_u c_then) (comp_res c_then) in let e_then_typing = T_Lift _ _ _ _ e_then_typing (Lift_STGhost_STAtomic _ _ w) in let (| c , e1_typing , e2_typing |) = combine_if_branches _ _ _ e_then_typing _ _ _ e_else_typing in (| c, e1_typing, e2_typing |) | _, C_STGhost _ _ -> let w = get_non_informative_witness g_else (comp_u c_else) (comp_res c_else) in let e_else_typing = T_Lift _ _ _ _ e_else_typing (Lift_STGhost_STAtomic _ _ w) in combine_if_branches _ _ _ e_then_typing _ _ _ e_else_typing | _, _ -> fail g None (Printf.sprintf "Cannot combine then and else branches (incompatible effects %s and %s resp.)" (P.ctag_to_string (ctag_of_comp_st c_then)) (P.ctag_to_string (ctag_of_comp_st c_else))) else fail g None "Cannot combine then and else branches (different st_comp)"
{ "checked_file": "Pulse.Checker.If.fst.checked", "dependencies": [ "Pulse.Typing.Metatheory.fsti.checked", "Pulse.Typing.Env.fsti.checked", "Pulse.Typing.Combinators.fsti.checked", "Pulse.Typing.fst.checked", "Pulse.Syntax.Printer.fsti.checked", "Pulse.Syntax.fst.checked", "Pulse.Checker.Pure.fsti.checked", "Pulse.Checker.Prover.fsti.checked", "Pulse.Checker.Base.fsti.checked", "prims.fst.checked", "FStar.Tactics.V2.fst.checked", "FStar.Set.fsti.checked", "FStar.Printf.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": true, "source_file": "Pulse.Checker.If.fst" }
[]
[ "Pulse.Typing.Env.env", "Pulse.Syntax.Base.st_term", "Pulse.Syntax.Base.comp_st", "Pulse.Typing.st_typing", "Pulse.Syntax.Base.eq_st_comp", "Pulse.Syntax.Base.st_comp_of_comp", "FStar.Pervasives.Native.Mktuple2", "Pulse.Syntax.Base.comp", "Pulse.Syntax.Base.st_comp", "FStar.Pervasives.Mkdtuple3", "Prims.eq2", "FStar.Pervasives.dtuple3", "Pulse.Syntax.Base.term", "Pulse.Syntax.Base.eq_tm", "Prims.bool", "Pulse.Typing.Env.fail", "FStar.Pervasives.Native.None", "Pulse.Syntax.Base.range", "Prims.string", "FStar.Printf.sprintf", "Pulse.Syntax.Printer.term_to_string", "Pulse.Syntax.Base.tm_emp_inames", "Pulse.Typing.T_Lift", "Pulse.Typing.Lift_STAtomic_ST", "Pulse.Syntax.Base.C_STAtomic", "Pulse.Syntax.Base.comp_inames", "Pulse.Checker.If.combine_if_branches", "Pulse.Typing.Lift_STGhost_STAtomic", "Pulse.Typing.non_informative_t", "Pulse.Syntax.Base.comp_u", "Pulse.Syntax.Base.comp_res", "Pulse.Checker.Pure.get_non_informative_witness", "Pulse.Syntax.Printer.ctag_to_string", "Pulse.Syntax.Base.ctag_of_comp_st", "FStar.Tactics.Types.proofstate", "Pulse.Syntax.Base.vprop", "Pulse.Syntax.Base.comp_pre", "FStar.Tactics.Result.__result", "Prims.l_True" ]
[]
module Pulse.Checker.If open Pulse.Syntax open Pulse.Typing open Pulse.Typing.Combinators open Pulse.Checker.Pure open Pulse.Checker.Base open Pulse.Checker.Prover module T = FStar.Tactics.V2 module P = Pulse.Syntax.Printer module Metatheory = Pulse.Typing.Metatheory #push-options "--z3rlimit_factor 16 --fuel 0 --ifuel 1" let rec combine_if_branches (g_then:env) (e_then:st_term) (c_then:comp_st) (e_then_typing:st_typing g_then e_then c_then) (g_else:env) (e_else:st_term) (c_else:comp_st) (e_else_typing:st_typing g_else e_else c_else) : T.TacH (c:comp_st{st_comp_of_comp c == st_comp_of_comp c_then} & st_typing g_then e_then c & st_typing g_else e_else c) (requires fun _ ->
false
false
Pulse.Checker.If.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 1, "max_fuel": 0, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 16, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val combine_if_branches (g_then: env) (e_then: st_term) (c_then: comp_st) (e_then_typing: st_typing g_then e_then c_then) (g_else: env) (e_else: st_term) (c_else: comp_st) (e_else_typing: st_typing g_else e_else c_else) : T.TacH (c: comp_st{st_comp_of_comp c == st_comp_of_comp c_then} & st_typing g_then e_then c & st_typing g_else e_else c) (requires fun _ -> comp_pre c_then == comp_pre c_else) (ensures fun _ _ -> True)
[ "recursion" ]
Pulse.Checker.If.combine_if_branches
{ "file_name": "lib/steel/pulse/Pulse.Checker.If.fst", "git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e", "git_url": "https://github.com/FStarLang/steel.git", "project_name": "steel" }
g_then: Pulse.Typing.Env.env -> e_then: Pulse.Syntax.Base.st_term -> c_then: Pulse.Syntax.Base.comp_st -> e_then_typing: Pulse.Typing.st_typing g_then e_then c_then -> g_else: Pulse.Typing.Env.env -> e_else: Pulse.Syntax.Base.st_term -> c_else: Pulse.Syntax.Base.comp_st -> e_else_typing: Pulse.Typing.st_typing g_else e_else c_else -> FStar.Tactics.Effect.TacH (FStar.Pervasives.dtuple3 (c: Pulse.Syntax.Base.comp_st {Pulse.Syntax.Base.st_comp_of_comp c == Pulse.Syntax.Base.st_comp_of_comp c_then}) (fun c -> Pulse.Typing.st_typing g_then e_then c) (fun c _ -> Pulse.Typing.st_typing g_else e_else c))
{ "end_col": 78, "end_line": 83, "start_col": 38, "start_line": 29 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let is_full_read (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) (i:int) = buffer_addr b h1 == buffer_addr b h2 /\ buffer_read b i h1 == buffer_read b i h2 /\ valid_buffer_read h1 b i
let is_full_read (#t: base_typ) (h1 h2: vale_heap) (b: buffer t) (i: int) =
false
null
false
buffer_addr b h1 == buffer_addr b h2 /\ buffer_read b i h1 == buffer_read b i h2 /\ valid_buffer_read h1 b i
{ "checked_file": "Vale.X64.Memory_Sems.fsti.checked", "dependencies": [ "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Memory_Sems.fsti" }
[ "total" ]
[ "Vale.Arch.HeapTypes_s.base_typ", "Vale.X64.Memory.vale_heap", "Vale.X64.Memory.buffer", "Prims.int", "Prims.l_and", "Prims.eq2", "Vale.X64.Memory.buffer_addr", "Vale.X64.Memory.base_typ_as_vale_type", "Vale.X64.Memory.buffer_read", "Vale.X64.Memory.valid_buffer_read", "Prims.logical" ]
[]
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.Arch.Heap open Vale.Arch.MachineHeap_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Lib.Seqs module S = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 val same_domain (h:vale_heap) (m:S.machine_heap) : prop0 val lemma_same_domains (h:vale_heap) (m1:S.machine_heap) (m2:S.machine_heap) : Lemma (requires same_domain h m1 /\ Set.equal (Map.domain m1) (Map.domain m2)) (ensures same_domain h m2) val get_heap (h:vale_heap) : GTot (m:S.machine_heap{same_domain h m}) val upd_heap (h:vale_heap) (m:S.machine_heap{is_machine_heap_update (get_heap h) m}) : GTot vale_heap //val lemma_upd_get_heap (h:vale_heap) : Lemma (upd_heap h (get_heap h) == h) // [SMTPat (upd_heap h (get_heap h))] val lemma_get_upd_heap (h:vale_heap) (m:S.machine_heap) : Lemma (requires is_machine_heap_update (get_heap h) m) (ensures get_heap (upd_heap h m) == m) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x val lemma_heap_impl : squash (heap_impl == vale_full_heap) val lemma_heap_get_heap (h:vale_full_heap) : Lemma (heap_get (coerce h) == get_heap (get_vale_heap h)) [SMTPat (heap_get (coerce h))] val lemma_heap_taint (h:vale_full_heap) : Lemma (heap_taint (coerce h) == full_heap_taint h) [SMTPat (heap_taint (coerce h))]
false
false
Vale.X64.Memory_Sems.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_full_read : h1: Vale.X64.Memory.vale_heap -> h2: Vale.X64.Memory.vale_heap -> b: Vale.X64.Memory.buffer t -> i: Prims.int -> Prims.logical
[]
Vale.X64.Memory_Sems.is_full_read
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
h1: Vale.X64.Memory.vale_heap -> h2: Vale.X64.Memory.vale_heap -> b: Vale.X64.Memory.buffer t -> i: Prims.int -> Prims.logical
{ "end_col": 26, "end_line": 48, "start_col": 2, "start_line": 46 }
Prims.Tot
val coerce (#b #a: Type) (x: a{a == b}) : b
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let coerce (#b #a:Type) (x:a{a == b}) : b = x
val coerce (#b #a: Type) (x: a{a == b}) : b let coerce (#b #a: Type) (x: a{a == b}) : b =
false
null
false
x
{ "checked_file": "Vale.X64.Memory_Sems.fsti.checked", "dependencies": [ "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Memory_Sems.fsti" }
[ "total" ]
[ "Prims.eq2" ]
[]
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.Arch.Heap open Vale.Arch.MachineHeap_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Lib.Seqs module S = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 val same_domain (h:vale_heap) (m:S.machine_heap) : prop0 val lemma_same_domains (h:vale_heap) (m1:S.machine_heap) (m2:S.machine_heap) : Lemma (requires same_domain h m1 /\ Set.equal (Map.domain m1) (Map.domain m2)) (ensures same_domain h m2) val get_heap (h:vale_heap) : GTot (m:S.machine_heap{same_domain h m}) val upd_heap (h:vale_heap) (m:S.machine_heap{is_machine_heap_update (get_heap h) m}) : GTot vale_heap //val lemma_upd_get_heap (h:vale_heap) : Lemma (upd_heap h (get_heap h) == h) // [SMTPat (upd_heap h (get_heap h))] val lemma_get_upd_heap (h:vale_heap) (m:S.machine_heap) : Lemma (requires is_machine_heap_update (get_heap h) m) (ensures get_heap (upd_heap h m) == m)
false
false
Vale.X64.Memory_Sems.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val coerce (#b #a: Type) (x: a{a == b}) : b
[]
Vale.X64.Memory_Sems.coerce
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: a{a == b} -> b
{ "end_col": 52, "end_line": 33, "start_col": 51, "start_line": 33 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.Lib.Map16", "short_module": "Map16" }, { "abbrev": true, "full_module": "Vale.X64.Machine_Semantics_s", "short_module": "S" }, { "abbrev": false, "full_module": "Vale.Lib.Seqs", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapImpl", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let is_full_update (vfh:vale_full_heap) (h':vale_heap) (hid:heaplet_id) (mh':machine_heap) (mt':memtaint) = is_machine_heap_update (heap_get (coerce vfh)) mh' /\ ( let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in mem_inv vfh' /\ vfh'.vf_layout == vfh.vf_layout /\ vfh'.vf_heaplets == Map16.upd vfh.vf_heaplets hid h' )
let is_full_update (vfh: vale_full_heap) (h': vale_heap) (hid: heaplet_id) (mh': machine_heap) (mt': memtaint) =
false
null
false
is_machine_heap_update (heap_get (coerce vfh)) mh' /\ (let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in mem_inv vfh' /\ vfh'.vf_layout == vfh.vf_layout /\ vfh'.vf_heaplets == Map16.upd vfh.vf_heaplets hid h')
{ "checked_file": "Vale.X64.Memory_Sems.fsti.checked", "dependencies": [ "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_Semantics_s.fst.checked", "Vale.X64.Machine_s.fst.checked", "Vale.Lib.Seqs.fsti.checked", "Vale.Lib.Map16.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Arch.Types.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapImpl.fsti.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Memory_Sems.fsti" }
[ "total" ]
[ "Vale.X64.Memory.vale_full_heap", "Vale.X64.Memory.vale_heap", "Vale.X64.Memory.heaplet_id", "Vale.Arch.MachineHeap_s.machine_heap", "Vale.X64.Memory.memtaint", "Prims.l_and", "Vale.Arch.MachineHeap_s.is_machine_heap_update", "Vale.Arch.Heap.heap_get", "Vale.X64.Memory_Sems.coerce", "Vale.Arch.Heap.heap_impl", "Vale.X64.Memory.mem_inv", "Prims.eq2", "Vale.Arch.HeapImpl.vale_heap_layout", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout", "Vale.Lib.Map16.map16", "Vale.Arch.HeapImpl.vale_heap", "Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets", "Vale.Lib.Map16.upd", "Vale.Arch.HeapImpl.vale_full_heap", "Vale.Arch.Heap.heap_upd", "Prims.logical" ]
[]
module Vale.X64.Memory_Sems open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Types_s open Vale.Arch.Types open Vale.Arch.HeapImpl open Vale.Arch.Heap open Vale.Arch.MachineHeap_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.Lib.Seqs module S = Vale.X64.Machine_Semantics_s module Map16 = Vale.Lib.Map16 val same_domain (h:vale_heap) (m:S.machine_heap) : prop0 val lemma_same_domains (h:vale_heap) (m1:S.machine_heap) (m2:S.machine_heap) : Lemma (requires same_domain h m1 /\ Set.equal (Map.domain m1) (Map.domain m2)) (ensures same_domain h m2) val get_heap (h:vale_heap) : GTot (m:S.machine_heap{same_domain h m}) val upd_heap (h:vale_heap) (m:S.machine_heap{is_machine_heap_update (get_heap h) m}) : GTot vale_heap //val lemma_upd_get_heap (h:vale_heap) : Lemma (upd_heap h (get_heap h) == h) // [SMTPat (upd_heap h (get_heap h))] val lemma_get_upd_heap (h:vale_heap) (m:S.machine_heap) : Lemma (requires is_machine_heap_update (get_heap h) m) (ensures get_heap (upd_heap h m) == m) unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x val lemma_heap_impl : squash (heap_impl == vale_full_heap) val lemma_heap_get_heap (h:vale_full_heap) : Lemma (heap_get (coerce h) == get_heap (get_vale_heap h)) [SMTPat (heap_get (coerce h))] val lemma_heap_taint (h:vale_full_heap) : Lemma (heap_taint (coerce h) == full_heap_taint h) [SMTPat (heap_taint (coerce h))] let is_full_read (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) (i:int) = buffer_addr b h1 == buffer_addr b h2 /\ buffer_read b i h1 == buffer_read b i h2 /\ valid_buffer_read h1 b i // needed to trigger "index = i" in valid_mem_operand64/valid_mem_operand128
false
true
Vale.X64.Memory_Sems.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val is_full_update : vfh: Vale.X64.Memory.vale_full_heap -> h': Vale.X64.Memory.vale_heap -> hid: Vale.X64.Memory.heaplet_id -> mh': Vale.Arch.MachineHeap_s.machine_heap -> mt': Vale.X64.Memory.memtaint -> Prims.logical
[]
Vale.X64.Memory_Sems.is_full_update
{ "file_name": "vale/code/arch/x64/Vale.X64.Memory_Sems.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
vfh: Vale.X64.Memory.vale_full_heap -> h': Vale.X64.Memory.vale_heap -> hid: Vale.X64.Memory.heaplet_id -> mh': Vale.Arch.MachineHeap_s.machine_heap -> mt': Vale.X64.Memory.memtaint -> Prims.logical
{ "end_col": 3, "end_line": 56, "start_col": 2, "start_line": 51 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1
let singleton_length_one_fact =
false
null
false
forall (ty: Type u#a) (v: ty). {:pattern length (singleton v)} length (singleton v) = 1
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Sequence.Base.length", "FStar.Sequence.Base.singleton" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1);
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val singleton_length_one_fact : Prims.logical
[]
FStar.Sequence.Base.singleton_length_one_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 88, "end_line": 172, "start_col": 2, "start_line": 172 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1
let append_sums_lengths_fact =
false
null
false
forall (ty: Type u#a) (s0: seq ty) (s1: seq ty). {:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Sequence.Base.length", "FStar.Sequence.Base.append", "Prims.op_Addition" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1));
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val append_sums_lengths_fact : Prims.logical
[]
FStar.Sequence.Base.append_sums_lengths_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 49, "end_line": 203, "start_col": 2, "start_line": 202 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0
let length_of_empty_is_zero_fact =
false
null
false
forall (ty: Type u#a). {:pattern empty #ty} length (empty #ty) = 0
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Sequence.Base.length", "FStar.Sequence.Base.empty" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0);
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val length_of_empty_is_zero_fact : Prims.logical
[]
FStar.Sequence.Base.length_of_empty_is_zero_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 67, "end_line": 157, "start_col": 2, "start_line": 157 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty
let length_zero_implies_empty_fact =
false
null
false
forall (ty: Type u#a) (s: seq ty). {:pattern length s} length s = 0 ==> s == empty
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.l_imp", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Sequence.Base.length", "Prims.eq2", "FStar.Sequence.Base.empty" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty())
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val length_zero_implies_empty_fact : Prims.logical
[]
FStar.Sequence.Base.length_zero_implies_empty_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 83, "end_line": 165, "start_col": 2, "start_line": 165 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s
let build_increments_length_fact =
false
null
false
forall (ty: Type u#a) (s: seq ty) (v: ty). {:pattern build s v} length (build s v) = 1 + length s
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.b2t", "Prims.op_Equality", "Prims.int", "FStar.Sequence.Base.length", "FStar.Sequence.Base.build", "Prims.op_Addition" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s));
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val build_increments_length_fact : Prims.logical
[]
FStar.Sequence.Base.build_increments_length_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 37, "end_line": 182, "start_col": 2, "start_line": 181 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let empty_doesnt_contain_anything_fact = forall (ty: Type u#a) (x: ty).{:pattern contains empty x} ~(contains empty x)
let empty_doesnt_contain_anything_fact =
false
null
false
forall (ty: Type u#a) (x: ty). {:pattern contains empty x} ~(contains empty x)
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.l_not", "FStar.Sequence.Base.contains", "FStar.Sequence.Base.empty" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1)); private let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1 /// We represent the following Dafny axiom with `index_into_singleton_fact`: /// /// axiom (forall<T> t: T :: { Seq#Index(Seq#Singleton(t), 0) } Seq#Index(Seq#Singleton(t), 0) == t); private let index_into_singleton_fact (_: squash (singleton_length_one_fact u#a)) = forall (ty: Type u#a) (v: ty).{:pattern index (singleton v) 0} index (singleton v) 0 == v /// We represent the following axiom with `index_after_append_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#Index(Seq#Append(s0,s1), n) } /// (n < Seq#Length(s0) ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s0, n)) && /// (Seq#Length(s0) <= n ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s1, n - Seq#Length(s0)))); private let index_after_append_fact (_: squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty) (n: nat{n < length (append s0 s1)}) .{:pattern index (append s0 s1) n} (n < length s0 ==> index (append s0 s1) n == index s0 n) /\ (length s0 <= n ==> index (append s0 s1) n == index s1 (n - length s0)) /// We represent the following Dafny axiom with `update_maintains_length`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Length(Seq#Update(s,i,v)) } /// 0 <= i && i < Seq#Length(s) ==> Seq#Length(Seq#Update(s,i,v)) == Seq#Length(s)); private let update_maintains_length_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)} length (update s i v) = length s /// We represent the following Dafny axiom with `update_then_index_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: { Seq#Index(Seq#Update(s,i,v),n) } /// 0 <= n && n < Seq#Length(s) ==> /// (i == n ==> Seq#Index(Seq#Update(s,i,v),n) == v) && /// (i != n ==> Seq#Index(Seq#Update(s,i,v),n) == Seq#Index(s,n))); private let update_then_index_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty) (n: nat{n < length (update s i v)}) .{:pattern index (update s i v) n} n < length s ==> (i = n ==> index (update s i v) n == v) /\ (i <> n ==> index (update s i v) n == index s n) /// We represent the following Dafny axiom with `contains_iff_exists_index_fact`: /// /// axiom (forall<T> s: Seq T, x: T :: { Seq#Contains(s,x) } /// Seq#Contains(s,x) <==> /// (exists i: int :: { Seq#Index(s,i) } 0 <= i && i < Seq#Length(s) && Seq#Index(s,i) == x)); private let contains_iff_exists_index_fact = forall (ty: Type u#a) (s: seq ty) (x: ty).{:pattern contains s x} contains s x <==> (exists (i: nat).{:pattern index s i} i < length s /\ index s i == x) /// We represent the following Dafny axiom with `empty_doesnt_contain_fact`: /// /// axiom (forall<T> x: T :: /// { Seq#Contains(Seq#Empty(), x) } /// !Seq#Contains(Seq#Empty(), x));
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val empty_doesnt_contain_anything_fact : Prims.logical
[]
FStar.Sequence.Base.empty_doesnt_contain_anything_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 79, "end_line": 265, "start_col": 2, "start_line": 265 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_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_iff_exists_index_fact = forall (ty: Type u#a) (s: seq ty) (x: ty).{:pattern contains s x} contains s x <==> (exists (i: nat).{:pattern index s i} i < length s /\ index s i == x)
let contains_iff_exists_index_fact =
false
null
false
forall (ty: Type u#a) (s: seq ty) (x: ty). {:pattern contains s x} contains s x <==> (exists (i: nat). {:pattern index s i} i < length s /\ index s i == x)
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.l_iff", "FStar.Sequence.Base.contains", "Prims.l_Exists", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.Sequence.Base.length", "Prims.eq2", "FStar.Sequence.Base.index" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1)); private let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1 /// We represent the following Dafny axiom with `index_into_singleton_fact`: /// /// axiom (forall<T> t: T :: { Seq#Index(Seq#Singleton(t), 0) } Seq#Index(Seq#Singleton(t), 0) == t); private let index_into_singleton_fact (_: squash (singleton_length_one_fact u#a)) = forall (ty: Type u#a) (v: ty).{:pattern index (singleton v) 0} index (singleton v) 0 == v /// We represent the following axiom with `index_after_append_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#Index(Seq#Append(s0,s1), n) } /// (n < Seq#Length(s0) ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s0, n)) && /// (Seq#Length(s0) <= n ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s1, n - Seq#Length(s0)))); private let index_after_append_fact (_: squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty) (n: nat{n < length (append s0 s1)}) .{:pattern index (append s0 s1) n} (n < length s0 ==> index (append s0 s1) n == index s0 n) /\ (length s0 <= n ==> index (append s0 s1) n == index s1 (n - length s0)) /// We represent the following Dafny axiom with `update_maintains_length`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Length(Seq#Update(s,i,v)) } /// 0 <= i && i < Seq#Length(s) ==> Seq#Length(Seq#Update(s,i,v)) == Seq#Length(s)); private let update_maintains_length_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)} length (update s i v) = length s /// We represent the following Dafny axiom with `update_then_index_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: { Seq#Index(Seq#Update(s,i,v),n) } /// 0 <= n && n < Seq#Length(s) ==> /// (i == n ==> Seq#Index(Seq#Update(s,i,v),n) == v) && /// (i != n ==> Seq#Index(Seq#Update(s,i,v),n) == Seq#Index(s,n))); private let update_then_index_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty) (n: nat{n < length (update s i v)}) .{:pattern index (update s i v) n} n < length s ==> (i = n ==> index (update s i v) n == v) /\ (i <> n ==> index (update s i v) n == index s n) /// We represent the following Dafny axiom with `contains_iff_exists_index_fact`: /// /// axiom (forall<T> s: Seq T, x: T :: { Seq#Contains(s,x) } /// Seq#Contains(s,x) <==> /// (exists i: int :: { Seq#Index(s,i) } 0 <= i && i < Seq#Length(s) && Seq#Index(s,i) == x));
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val contains_iff_exists_index_fact : Prims.logical
[]
FStar.Sequence.Base.contains_iff_exists_index_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 91, "end_line": 256, "start_col": 2, "start_line": 255 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rank_def_fact = forall (ty: Type u#a) (v: ty).{:pattern rank v} rank v == v
let rank_def_fact =
false
null
false
forall (ty: Type u#a) (v: ty). {:pattern rank v} rank v == v
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "Prims.eq2", "FStar.Sequence.Base.rank" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1)); private let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1 /// We represent the following Dafny axiom with `index_into_singleton_fact`: /// /// axiom (forall<T> t: T :: { Seq#Index(Seq#Singleton(t), 0) } Seq#Index(Seq#Singleton(t), 0) == t); private let index_into_singleton_fact (_: squash (singleton_length_one_fact u#a)) = forall (ty: Type u#a) (v: ty).{:pattern index (singleton v) 0} index (singleton v) 0 == v /// We represent the following axiom with `index_after_append_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#Index(Seq#Append(s0,s1), n) } /// (n < Seq#Length(s0) ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s0, n)) && /// (Seq#Length(s0) <= n ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s1, n - Seq#Length(s0)))); private let index_after_append_fact (_: squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty) (n: nat{n < length (append s0 s1)}) .{:pattern index (append s0 s1) n} (n < length s0 ==> index (append s0 s1) n == index s0 n) /\ (length s0 <= n ==> index (append s0 s1) n == index s1 (n - length s0)) /// We represent the following Dafny axiom with `update_maintains_length`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Length(Seq#Update(s,i,v)) } /// 0 <= i && i < Seq#Length(s) ==> Seq#Length(Seq#Update(s,i,v)) == Seq#Length(s)); private let update_maintains_length_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)} length (update s i v) = length s /// We represent the following Dafny axiom with `update_then_index_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: { Seq#Index(Seq#Update(s,i,v),n) } /// 0 <= n && n < Seq#Length(s) ==> /// (i == n ==> Seq#Index(Seq#Update(s,i,v),n) == v) && /// (i != n ==> Seq#Index(Seq#Update(s,i,v),n) == Seq#Index(s,n))); private let update_then_index_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty) (n: nat{n < length (update s i v)}) .{:pattern index (update s i v) n} n < length s ==> (i = n ==> index (update s i v) n == v) /\ (i <> n ==> index (update s i v) n == index s n) /// We represent the following Dafny axiom with `contains_iff_exists_index_fact`: /// /// axiom (forall<T> s: Seq T, x: T :: { Seq#Contains(s,x) } /// Seq#Contains(s,x) <==> /// (exists i: int :: { Seq#Index(s,i) } 0 <= i && i < Seq#Length(s) && Seq#Index(s,i) == x)); private let contains_iff_exists_index_fact = forall (ty: Type u#a) (s: seq ty) (x: ty).{:pattern contains s x} contains s x <==> (exists (i: nat).{:pattern index s i} i < length s /\ index s i == x) /// We represent the following Dafny axiom with `empty_doesnt_contain_fact`: /// /// axiom (forall<T> x: T :: /// { Seq#Contains(Seq#Empty(), x) } /// !Seq#Contains(Seq#Empty(), x)); private let empty_doesnt_contain_anything_fact = forall (ty: Type u#a) (x: ty).{:pattern contains empty x} ~(contains empty x) /// We represent the following Dafny axiom with `build_contains_equiv_fact`: /// /// axiom (forall<T> s: Seq T, v: T, x: T :: // needed to prove things like '4 in [2,3,4]', see method TestSequences0 in SmallTests.dfy /// { Seq#Contains(Seq#Build(s, v), x) } /// Seq#Contains(Seq#Build(s, v), x) <==> (v == x || Seq#Contains(s, x))); private let build_contains_equiv_fact = forall (ty: Type u#a) (s: seq ty) (v: ty) (x: ty).{:pattern contains (build s v) x} contains (build s v) x <==> (v == x \/ contains s x) /// We represent the following Dafny axiom with `take_contains_equiv_exists_fact`: /// /// axiom (forall<T> s: Seq T, n: int, x: T :: /// { Seq#Contains(Seq#Take(s, n), x) } /// Seq#Contains(Seq#Take(s, n), x) <==> /// (exists i: int :: { Seq#Index(s, i) } /// 0 <= i && i < n && i < Seq#Length(s) && Seq#Index(s, i) == x)); private let take_contains_equiv_exists_fact = forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (take s n) x} contains (take s n) x <==> (exists (i: nat).{:pattern index s i} i < n /\ i < length s /\ index s i == x) /// We represent the following Dafny axiom with `drop_contains_equiv_exists_fact`: /// /// axiom (forall<T> s: Seq T, n: int, x: T :: /// { Seq#Contains(Seq#Drop(s, n), x) } /// Seq#Contains(Seq#Drop(s, n), x) <==> /// (exists i: int :: { Seq#Index(s, i) } /// 0 <= n && n <= i && i < Seq#Length(s) && Seq#Index(s, i) == x)); private let drop_contains_equiv_exists_fact = forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (drop s n) x} contains (drop s n) x <==> (exists (i: nat).{:pattern index s i} n <= i && i < length s /\ index s i == x) /// We represent the following Dafny axiom with `equal_def_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Equal(s0,s1) } /// Seq#Equal(s0,s1) <==> /// Seq#Length(s0) == Seq#Length(s1) && /// (forall j: int :: { Seq#Index(s0,j) } { Seq#Index(s1,j) } /// 0 <= j && j < Seq#Length(s0) ==> Seq#Index(s0,j) == Seq#Index(s1,j))); private let equal_def_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern equal s0 s1} equal s0 s1 <==> length s0 == length s1 /\ (forall j.{:pattern index s0 j \/ index s1 j} 0 <= j && j < length s0 ==> index s0 j == index s1 j) /// We represent the following Dafny axiom with `extensionality_fact`: /// /// axiom (forall<T> a: Seq T, b: Seq T :: { Seq#Equal(a,b) } // extensionality axiom for sequences /// Seq#Equal(a,b) ==> a == b); private let extensionality_fact = forall (ty: Type u#a) (a: seq ty) (b: seq ty).{:pattern equal a b} equal a b ==> a == b /// We represent an analog of the following Dafny axiom with /// `is_prefix_def_fact`. Our analog uses `is_prefix` instead /// of `Seq#SameUntil`. /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#SameUntil(s0,s1,n) } /// Seq#SameUntil(s0,s1,n) <==> /// (forall j: int :: { Seq#Index(s0,j) } { Seq#Index(s1,j) } /// 0 <= j && j < n ==> Seq#Index(s0,j) == Seq#Index(s1,j))); private let is_prefix_def_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern is_prefix s0 s1} is_prefix s0 s1 <==> length s0 <= length s1 /\ (forall (j: nat).{:pattern index s0 j \/ index s1 j} j < length s0 ==> index s0 j == index s1 j) /// We represent the following Dafny axiom with `take_length_fact`: /// /// axiom (forall<T> s: Seq T, n: int :: { Seq#Length(Seq#Take(s,n)) } /// 0 <= n && n <= Seq#Length(s) ==> Seq#Length(Seq#Take(s,n)) == n); private let take_length_fact = forall (ty: Type u#a) (s: seq ty) (n: nat).{:pattern length (take s n)} n <= length s ==> length (take s n) = n /// We represent the following Dafny axiom with `index_into_take_fact`. /// /// axiom (forall<T> s: Seq T, n: int, j: int :: /// {:weight 25} /// { Seq#Index(Seq#Take(s,n), j) } /// { Seq#Index(s, j), Seq#Take(s,n) } /// 0 <= j && j < n && j < Seq#Length(s) ==> /// Seq#Index(Seq#Take(s,n), j) == Seq#Index(s, j)); private let index_into_take_fact (_ : squash (take_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (n: nat) (j: nat). {:pattern index (take s n) j \/ index s j ; take s n} j < n && n <= length s ==> index (take s n) j == index s j /// We represent the following Dafny axiom with `drop_length_fact`. /// /// axiom (forall<T> s: Seq T, n: int :: { Seq#Length(Seq#Drop(s,n)) } /// 0 <= n && n <= Seq#Length(s) ==> Seq#Length(Seq#Drop(s,n)) == Seq#Length(s) - n); private let drop_length_fact = forall (ty: Type u#a) (s: seq ty) (n: nat). {:pattern length (drop s n)} n <= length s ==> length (drop s n) = length s - n /// We represent the following Dafny axiom with `index_into_drop_fact`. /// /// axiom (forall<T> s: Seq T, n: int, j: int :: /// {:weight 25} /// { Seq#Index(Seq#Drop(s,n), j) } /// 0 <= n && 0 <= j && j < Seq#Length(s)-n ==> /// Seq#Index(Seq#Drop(s,n), j) == Seq#Index(s, j+n)); private let index_into_drop_fact (_ : squash (drop_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (n: nat) (j: nat). {:pattern index (drop s n) j} j < length s - n ==> index (drop s n) j == index s (j + n) /// We represent the following Dafny axiom with `drop_index_offset_fact`. /// /// axiom (forall<T> s: Seq T, n: int, k: int :: /// {:weight 25} /// { Seq#Index(s, k), Seq#Drop(s,n) } /// 0 <= n && n <= k && k < Seq#Length(s) ==> /// Seq#Index(Seq#Drop(s,n), k-n) == Seq#Index(s, k)); private let drop_index_offset_fact (_ : squash (drop_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (n: nat) (k: nat). {:pattern index s k; drop s n} n <= k && k < length s ==> index (drop s n) (k - n) == index s k /// We represent the following Dafny axiom with `append_then_take_or_drop_fact`. /// /// axiom (forall<T> s, t: Seq T, n: int :: /// { Seq#Take(Seq#Append(s, t), n) } /// { Seq#Drop(Seq#Append(s, t), n) } /// n == Seq#Length(s) /// ==> /// Seq#Take(Seq#Append(s, t), n) == s && /// Seq#Drop(Seq#Append(s, t), n) == t); private let append_then_take_or_drop_fact (_ : squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (t: seq ty) (n: nat). {:pattern take (append s t) n \/ drop (append s t) n} n = length s ==> take (append s t) n == s /\ drop (append s t) n == t /// We represent the following Dafny axiom with `take_commutes_with_in_range_update_fact`. /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: /// { Seq#Take(Seq#Update(s, i, v), n) } /// 0 <= i && i < n && n <= Seq#Length(s) ==> /// Seq#Take(Seq#Update(s, i, v), n) == Seq#Update(Seq#Take(s, n), i, v) ); private let take_commutes_with_in_range_update_fact (_ : squash (update_maintains_length_fact u#a /\ take_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (i: nat) (v: ty) (n: nat).{:pattern take (update s i v) n} i < n && n <= length s ==> take (update s i v) n == update (take s n) i v /// We represent the following Dafny axiom with `take_ignores_out_of_range_update_fact`. /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: /// { Seq#Take(Seq#Update(s, i, v), n) } /// n <= i && i < Seq#Length(s) ==> Seq#Take(Seq#Update(s, i, v), n) == Seq#Take(s, n)); private let take_ignores_out_of_range_update_fact (_ : squash (update_maintains_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (i: nat) (v: ty) (n: nat).{:pattern take (update s i v) n} n <= i && i < length s ==> take (update s i v) n == take s n /// We represent the following Dafny axiom with `drop_commutes_with_in_range_update_fact`. /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: /// { Seq#Drop(Seq#Update(s, i, v), n) } /// 0 <= n && n <= i && i < Seq#Length(s) ==> /// Seq#Drop(Seq#Update(s, i, v), n) == Seq#Update(Seq#Drop(s, n), i-n, v) ); private let drop_commutes_with_in_range_update_fact (_ : squash (update_maintains_length_fact u#a /\ drop_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (i: nat) (v: ty) (n: nat).{:pattern drop (update s i v) n} n <= i && i < length s ==> drop (update s i v) n == update (drop s n) (i - n) v /// We represent the following Dafny axiom with `drop_ignores_out_of_range_update_fact`. /// Jay noticed that it was unnecessarily weak, possibly due to a typo, so he reported this as /// Dafny issue #1423 (https://github.com/dafny-lang/dafny/issues/1423) and updated it here. /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: /// { Seq#Drop(Seq#Update(s, i, v), n) } /// 0 <= i && i < n && n < Seq#Length(s) ==> Seq#Drop(Seq#Update(s, i, v), n) == Seq#Drop(s, n)); private let drop_ignores_out_of_range_update_fact (_ : squash (update_maintains_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (i: nat) (v: ty) (n: nat).{:pattern drop (update s i v) n} i < n && n <= length s ==> drop (update s i v) n == drop s n /// We represent the following Dafny axiom with `drop_commutes_with_build_fact`. /// /// axiom (forall<T> s: Seq T, v: T, n: int :: /// { Seq#Drop(Seq#Build(s, v), n) } /// 0 <= n && n <= Seq#Length(s) ==> /// Seq#Drop(Seq#Build(s, v), n) == Seq#Build(Seq#Drop(s, n), v) ); private let drop_commutes_with_build_fact (_ : squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (n: nat).{:pattern drop (build s v) n} n <= length s ==> drop (build s v) n == build (drop s n) v /// We include the definition of `rank` among our facts.
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val rank_def_fact : Prims.logical
[]
FStar.Sequence.Base.rank_def_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 61, "end_line": 481, "start_col": 2, "start_line": 481 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let drop_length_fact = forall (ty: Type u#a) (s: seq ty) (n: nat). {:pattern length (drop s n)} n <= length s ==> length (drop s n) = length s - n
let drop_length_fact =
false
null
false
forall (ty: Type u#a) (s: seq ty) (n: nat). {:pattern length (drop s n)} n <= length s ==> length (drop s n) = length s - n
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Sequence.Base.length", "Prims.op_Equality", "Prims.int", "FStar.Sequence.Base.drop", "Prims.op_Subtraction" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1)); private let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1 /// We represent the following Dafny axiom with `index_into_singleton_fact`: /// /// axiom (forall<T> t: T :: { Seq#Index(Seq#Singleton(t), 0) } Seq#Index(Seq#Singleton(t), 0) == t); private let index_into_singleton_fact (_: squash (singleton_length_one_fact u#a)) = forall (ty: Type u#a) (v: ty).{:pattern index (singleton v) 0} index (singleton v) 0 == v /// We represent the following axiom with `index_after_append_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#Index(Seq#Append(s0,s1), n) } /// (n < Seq#Length(s0) ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s0, n)) && /// (Seq#Length(s0) <= n ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s1, n - Seq#Length(s0)))); private let index_after_append_fact (_: squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty) (n: nat{n < length (append s0 s1)}) .{:pattern index (append s0 s1) n} (n < length s0 ==> index (append s0 s1) n == index s0 n) /\ (length s0 <= n ==> index (append s0 s1) n == index s1 (n - length s0)) /// We represent the following Dafny axiom with `update_maintains_length`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Length(Seq#Update(s,i,v)) } /// 0 <= i && i < Seq#Length(s) ==> Seq#Length(Seq#Update(s,i,v)) == Seq#Length(s)); private let update_maintains_length_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)} length (update s i v) = length s /// We represent the following Dafny axiom with `update_then_index_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: { Seq#Index(Seq#Update(s,i,v),n) } /// 0 <= n && n < Seq#Length(s) ==> /// (i == n ==> Seq#Index(Seq#Update(s,i,v),n) == v) && /// (i != n ==> Seq#Index(Seq#Update(s,i,v),n) == Seq#Index(s,n))); private let update_then_index_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty) (n: nat{n < length (update s i v)}) .{:pattern index (update s i v) n} n < length s ==> (i = n ==> index (update s i v) n == v) /\ (i <> n ==> index (update s i v) n == index s n) /// We represent the following Dafny axiom with `contains_iff_exists_index_fact`: /// /// axiom (forall<T> s: Seq T, x: T :: { Seq#Contains(s,x) } /// Seq#Contains(s,x) <==> /// (exists i: int :: { Seq#Index(s,i) } 0 <= i && i < Seq#Length(s) && Seq#Index(s,i) == x)); private let contains_iff_exists_index_fact = forall (ty: Type u#a) (s: seq ty) (x: ty).{:pattern contains s x} contains s x <==> (exists (i: nat).{:pattern index s i} i < length s /\ index s i == x) /// We represent the following Dafny axiom with `empty_doesnt_contain_fact`: /// /// axiom (forall<T> x: T :: /// { Seq#Contains(Seq#Empty(), x) } /// !Seq#Contains(Seq#Empty(), x)); private let empty_doesnt_contain_anything_fact = forall (ty: Type u#a) (x: ty).{:pattern contains empty x} ~(contains empty x) /// We represent the following Dafny axiom with `build_contains_equiv_fact`: /// /// axiom (forall<T> s: Seq T, v: T, x: T :: // needed to prove things like '4 in [2,3,4]', see method TestSequences0 in SmallTests.dfy /// { Seq#Contains(Seq#Build(s, v), x) } /// Seq#Contains(Seq#Build(s, v), x) <==> (v == x || Seq#Contains(s, x))); private let build_contains_equiv_fact = forall (ty: Type u#a) (s: seq ty) (v: ty) (x: ty).{:pattern contains (build s v) x} contains (build s v) x <==> (v == x \/ contains s x) /// We represent the following Dafny axiom with `take_contains_equiv_exists_fact`: /// /// axiom (forall<T> s: Seq T, n: int, x: T :: /// { Seq#Contains(Seq#Take(s, n), x) } /// Seq#Contains(Seq#Take(s, n), x) <==> /// (exists i: int :: { Seq#Index(s, i) } /// 0 <= i && i < n && i < Seq#Length(s) && Seq#Index(s, i) == x)); private let take_contains_equiv_exists_fact = forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (take s n) x} contains (take s n) x <==> (exists (i: nat).{:pattern index s i} i < n /\ i < length s /\ index s i == x) /// We represent the following Dafny axiom with `drop_contains_equiv_exists_fact`: /// /// axiom (forall<T> s: Seq T, n: int, x: T :: /// { Seq#Contains(Seq#Drop(s, n), x) } /// Seq#Contains(Seq#Drop(s, n), x) <==> /// (exists i: int :: { Seq#Index(s, i) } /// 0 <= n && n <= i && i < Seq#Length(s) && Seq#Index(s, i) == x)); private let drop_contains_equiv_exists_fact = forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (drop s n) x} contains (drop s n) x <==> (exists (i: nat).{:pattern index s i} n <= i && i < length s /\ index s i == x) /// We represent the following Dafny axiom with `equal_def_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Equal(s0,s1) } /// Seq#Equal(s0,s1) <==> /// Seq#Length(s0) == Seq#Length(s1) && /// (forall j: int :: { Seq#Index(s0,j) } { Seq#Index(s1,j) } /// 0 <= j && j < Seq#Length(s0) ==> Seq#Index(s0,j) == Seq#Index(s1,j))); private let equal_def_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern equal s0 s1} equal s0 s1 <==> length s0 == length s1 /\ (forall j.{:pattern index s0 j \/ index s1 j} 0 <= j && j < length s0 ==> index s0 j == index s1 j) /// We represent the following Dafny axiom with `extensionality_fact`: /// /// axiom (forall<T> a: Seq T, b: Seq T :: { Seq#Equal(a,b) } // extensionality axiom for sequences /// Seq#Equal(a,b) ==> a == b); private let extensionality_fact = forall (ty: Type u#a) (a: seq ty) (b: seq ty).{:pattern equal a b} equal a b ==> a == b /// We represent an analog of the following Dafny axiom with /// `is_prefix_def_fact`. Our analog uses `is_prefix` instead /// of `Seq#SameUntil`. /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#SameUntil(s0,s1,n) } /// Seq#SameUntil(s0,s1,n) <==> /// (forall j: int :: { Seq#Index(s0,j) } { Seq#Index(s1,j) } /// 0 <= j && j < n ==> Seq#Index(s0,j) == Seq#Index(s1,j))); private let is_prefix_def_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern is_prefix s0 s1} is_prefix s0 s1 <==> length s0 <= length s1 /\ (forall (j: nat).{:pattern index s0 j \/ index s1 j} j < length s0 ==> index s0 j == index s1 j) /// We represent the following Dafny axiom with `take_length_fact`: /// /// axiom (forall<T> s: Seq T, n: int :: { Seq#Length(Seq#Take(s,n)) } /// 0 <= n && n <= Seq#Length(s) ==> Seq#Length(Seq#Take(s,n)) == n); private let take_length_fact = forall (ty: Type u#a) (s: seq ty) (n: nat).{:pattern length (take s n)} n <= length s ==> length (take s n) = n /// We represent the following Dafny axiom with `index_into_take_fact`. /// /// axiom (forall<T> s: Seq T, n: int, j: int :: /// {:weight 25} /// { Seq#Index(Seq#Take(s,n), j) } /// { Seq#Index(s, j), Seq#Take(s,n) } /// 0 <= j && j < n && j < Seq#Length(s) ==> /// Seq#Index(Seq#Take(s,n), j) == Seq#Index(s, j)); private let index_into_take_fact (_ : squash (take_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (n: nat) (j: nat). {:pattern index (take s n) j \/ index s j ; take s n} j < n && n <= length s ==> index (take s n) j == index s j /// We represent the following Dafny axiom with `drop_length_fact`. /// /// axiom (forall<T> s: Seq T, n: int :: { Seq#Length(Seq#Drop(s,n)) } /// 0 <= n && n <= Seq#Length(s) ==> Seq#Length(Seq#Drop(s,n)) == Seq#Length(s) - n);
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val drop_length_fact : Prims.logical
[]
FStar.Sequence.Base.drop_length_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 54, "end_line": 374, "start_col": 2, "start_line": 372 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let extensionality_fact = forall (ty: Type u#a) (a: seq ty) (b: seq ty).{:pattern equal a b} equal a b ==> a == b
let extensionality_fact =
false
null
false
forall (ty: Type u#a) (a: seq ty) (b: seq ty). {:pattern equal a b} equal a b ==> a == b
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.l_imp", "FStar.Sequence.Base.equal", "Prims.eq2" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1)); private let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1 /// We represent the following Dafny axiom with `index_into_singleton_fact`: /// /// axiom (forall<T> t: T :: { Seq#Index(Seq#Singleton(t), 0) } Seq#Index(Seq#Singleton(t), 0) == t); private let index_into_singleton_fact (_: squash (singleton_length_one_fact u#a)) = forall (ty: Type u#a) (v: ty).{:pattern index (singleton v) 0} index (singleton v) 0 == v /// We represent the following axiom with `index_after_append_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#Index(Seq#Append(s0,s1), n) } /// (n < Seq#Length(s0) ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s0, n)) && /// (Seq#Length(s0) <= n ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s1, n - Seq#Length(s0)))); private let index_after_append_fact (_: squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty) (n: nat{n < length (append s0 s1)}) .{:pattern index (append s0 s1) n} (n < length s0 ==> index (append s0 s1) n == index s0 n) /\ (length s0 <= n ==> index (append s0 s1) n == index s1 (n - length s0)) /// We represent the following Dafny axiom with `update_maintains_length`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Length(Seq#Update(s,i,v)) } /// 0 <= i && i < Seq#Length(s) ==> Seq#Length(Seq#Update(s,i,v)) == Seq#Length(s)); private let update_maintains_length_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)} length (update s i v) = length s /// We represent the following Dafny axiom with `update_then_index_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: { Seq#Index(Seq#Update(s,i,v),n) } /// 0 <= n && n < Seq#Length(s) ==> /// (i == n ==> Seq#Index(Seq#Update(s,i,v),n) == v) && /// (i != n ==> Seq#Index(Seq#Update(s,i,v),n) == Seq#Index(s,n))); private let update_then_index_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty) (n: nat{n < length (update s i v)}) .{:pattern index (update s i v) n} n < length s ==> (i = n ==> index (update s i v) n == v) /\ (i <> n ==> index (update s i v) n == index s n) /// We represent the following Dafny axiom with `contains_iff_exists_index_fact`: /// /// axiom (forall<T> s: Seq T, x: T :: { Seq#Contains(s,x) } /// Seq#Contains(s,x) <==> /// (exists i: int :: { Seq#Index(s,i) } 0 <= i && i < Seq#Length(s) && Seq#Index(s,i) == x)); private let contains_iff_exists_index_fact = forall (ty: Type u#a) (s: seq ty) (x: ty).{:pattern contains s x} contains s x <==> (exists (i: nat).{:pattern index s i} i < length s /\ index s i == x) /// We represent the following Dafny axiom with `empty_doesnt_contain_fact`: /// /// axiom (forall<T> x: T :: /// { Seq#Contains(Seq#Empty(), x) } /// !Seq#Contains(Seq#Empty(), x)); private let empty_doesnt_contain_anything_fact = forall (ty: Type u#a) (x: ty).{:pattern contains empty x} ~(contains empty x) /// We represent the following Dafny axiom with `build_contains_equiv_fact`: /// /// axiom (forall<T> s: Seq T, v: T, x: T :: // needed to prove things like '4 in [2,3,4]', see method TestSequences0 in SmallTests.dfy /// { Seq#Contains(Seq#Build(s, v), x) } /// Seq#Contains(Seq#Build(s, v), x) <==> (v == x || Seq#Contains(s, x))); private let build_contains_equiv_fact = forall (ty: Type u#a) (s: seq ty) (v: ty) (x: ty).{:pattern contains (build s v) x} contains (build s v) x <==> (v == x \/ contains s x) /// We represent the following Dafny axiom with `take_contains_equiv_exists_fact`: /// /// axiom (forall<T> s: Seq T, n: int, x: T :: /// { Seq#Contains(Seq#Take(s, n), x) } /// Seq#Contains(Seq#Take(s, n), x) <==> /// (exists i: int :: { Seq#Index(s, i) } /// 0 <= i && i < n && i < Seq#Length(s) && Seq#Index(s, i) == x)); private let take_contains_equiv_exists_fact = forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (take s n) x} contains (take s n) x <==> (exists (i: nat).{:pattern index s i} i < n /\ i < length s /\ index s i == x) /// We represent the following Dafny axiom with `drop_contains_equiv_exists_fact`: /// /// axiom (forall<T> s: Seq T, n: int, x: T :: /// { Seq#Contains(Seq#Drop(s, n), x) } /// Seq#Contains(Seq#Drop(s, n), x) <==> /// (exists i: int :: { Seq#Index(s, i) } /// 0 <= n && n <= i && i < Seq#Length(s) && Seq#Index(s, i) == x)); private let drop_contains_equiv_exists_fact = forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (drop s n) x} contains (drop s n) x <==> (exists (i: nat).{:pattern index s i} n <= i && i < length s /\ index s i == x) /// We represent the following Dafny axiom with `equal_def_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Equal(s0,s1) } /// Seq#Equal(s0,s1) <==> /// Seq#Length(s0) == Seq#Length(s1) && /// (forall j: int :: { Seq#Index(s0,j) } { Seq#Index(s1,j) } /// 0 <= j && j < Seq#Length(s0) ==> Seq#Index(s0,j) == Seq#Index(s1,j))); private let equal_def_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern equal s0 s1} equal s0 s1 <==> length s0 == length s1 /\ (forall j.{:pattern index s0 j \/ index s1 j} 0 <= j && j < length s0 ==> index s0 j == index s1 j) /// We represent the following Dafny axiom with `extensionality_fact`: /// /// axiom (forall<T> a: Seq T, b: Seq T :: { Seq#Equal(a,b) } // extensionality axiom for sequences /// Seq#Equal(a,b) ==> a == b);
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val extensionality_fact : Prims.logical
[]
FStar.Sequence.Base.extensionality_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 24, "end_line": 325, "start_col": 2, "start_line": 324 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let element_ranks_less_fact = forall (ty: Type u#a) (s: seq ty) (i: nat).{:pattern rank (index s i)} i < length s ==> rank (index s i) << rank s
let element_ranks_less_fact =
false
null
false
forall (ty: Type u#a) (s: seq ty) (i: nat). {:pattern rank (index s i)} i < length s ==> rank (index s i) << rank s
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.nat", "Prims.l_imp", "Prims.b2t", "Prims.op_LessThan", "FStar.Sequence.Base.length", "Prims.precedes", "FStar.Sequence.Base.rank", "FStar.Sequence.Base.index" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1)); private let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1 /// We represent the following Dafny axiom with `index_into_singleton_fact`: /// /// axiom (forall<T> t: T :: { Seq#Index(Seq#Singleton(t), 0) } Seq#Index(Seq#Singleton(t), 0) == t); private let index_into_singleton_fact (_: squash (singleton_length_one_fact u#a)) = forall (ty: Type u#a) (v: ty).{:pattern index (singleton v) 0} index (singleton v) 0 == v /// We represent the following axiom with `index_after_append_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#Index(Seq#Append(s0,s1), n) } /// (n < Seq#Length(s0) ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s0, n)) && /// (Seq#Length(s0) <= n ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s1, n - Seq#Length(s0)))); private let index_after_append_fact (_: squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty) (n: nat{n < length (append s0 s1)}) .{:pattern index (append s0 s1) n} (n < length s0 ==> index (append s0 s1) n == index s0 n) /\ (length s0 <= n ==> index (append s0 s1) n == index s1 (n - length s0)) /// We represent the following Dafny axiom with `update_maintains_length`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Length(Seq#Update(s,i,v)) } /// 0 <= i && i < Seq#Length(s) ==> Seq#Length(Seq#Update(s,i,v)) == Seq#Length(s)); private let update_maintains_length_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)} length (update s i v) = length s /// We represent the following Dafny axiom with `update_then_index_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: { Seq#Index(Seq#Update(s,i,v),n) } /// 0 <= n && n < Seq#Length(s) ==> /// (i == n ==> Seq#Index(Seq#Update(s,i,v),n) == v) && /// (i != n ==> Seq#Index(Seq#Update(s,i,v),n) == Seq#Index(s,n))); private let update_then_index_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty) (n: nat{n < length (update s i v)}) .{:pattern index (update s i v) n} n < length s ==> (i = n ==> index (update s i v) n == v) /\ (i <> n ==> index (update s i v) n == index s n) /// We represent the following Dafny axiom with `contains_iff_exists_index_fact`: /// /// axiom (forall<T> s: Seq T, x: T :: { Seq#Contains(s,x) } /// Seq#Contains(s,x) <==> /// (exists i: int :: { Seq#Index(s,i) } 0 <= i && i < Seq#Length(s) && Seq#Index(s,i) == x)); private let contains_iff_exists_index_fact = forall (ty: Type u#a) (s: seq ty) (x: ty).{:pattern contains s x} contains s x <==> (exists (i: nat).{:pattern index s i} i < length s /\ index s i == x) /// We represent the following Dafny axiom with `empty_doesnt_contain_fact`: /// /// axiom (forall<T> x: T :: /// { Seq#Contains(Seq#Empty(), x) } /// !Seq#Contains(Seq#Empty(), x)); private let empty_doesnt_contain_anything_fact = forall (ty: Type u#a) (x: ty).{:pattern contains empty x} ~(contains empty x) /// We represent the following Dafny axiom with `build_contains_equiv_fact`: /// /// axiom (forall<T> s: Seq T, v: T, x: T :: // needed to prove things like '4 in [2,3,4]', see method TestSequences0 in SmallTests.dfy /// { Seq#Contains(Seq#Build(s, v), x) } /// Seq#Contains(Seq#Build(s, v), x) <==> (v == x || Seq#Contains(s, x))); private let build_contains_equiv_fact = forall (ty: Type u#a) (s: seq ty) (v: ty) (x: ty).{:pattern contains (build s v) x} contains (build s v) x <==> (v == x \/ contains s x) /// We represent the following Dafny axiom with `take_contains_equiv_exists_fact`: /// /// axiom (forall<T> s: Seq T, n: int, x: T :: /// { Seq#Contains(Seq#Take(s, n), x) } /// Seq#Contains(Seq#Take(s, n), x) <==> /// (exists i: int :: { Seq#Index(s, i) } /// 0 <= i && i < n && i < Seq#Length(s) && Seq#Index(s, i) == x)); private let take_contains_equiv_exists_fact = forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (take s n) x} contains (take s n) x <==> (exists (i: nat).{:pattern index s i} i < n /\ i < length s /\ index s i == x) /// We represent the following Dafny axiom with `drop_contains_equiv_exists_fact`: /// /// axiom (forall<T> s: Seq T, n: int, x: T :: /// { Seq#Contains(Seq#Drop(s, n), x) } /// Seq#Contains(Seq#Drop(s, n), x) <==> /// (exists i: int :: { Seq#Index(s, i) } /// 0 <= n && n <= i && i < Seq#Length(s) && Seq#Index(s, i) == x)); private let drop_contains_equiv_exists_fact = forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (drop s n) x} contains (drop s n) x <==> (exists (i: nat).{:pattern index s i} n <= i && i < length s /\ index s i == x) /// We represent the following Dafny axiom with `equal_def_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Equal(s0,s1) } /// Seq#Equal(s0,s1) <==> /// Seq#Length(s0) == Seq#Length(s1) && /// (forall j: int :: { Seq#Index(s0,j) } { Seq#Index(s1,j) } /// 0 <= j && j < Seq#Length(s0) ==> Seq#Index(s0,j) == Seq#Index(s1,j))); private let equal_def_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern equal s0 s1} equal s0 s1 <==> length s0 == length s1 /\ (forall j.{:pattern index s0 j \/ index s1 j} 0 <= j && j < length s0 ==> index s0 j == index s1 j) /// We represent the following Dafny axiom with `extensionality_fact`: /// /// axiom (forall<T> a: Seq T, b: Seq T :: { Seq#Equal(a,b) } // extensionality axiom for sequences /// Seq#Equal(a,b) ==> a == b); private let extensionality_fact = forall (ty: Type u#a) (a: seq ty) (b: seq ty).{:pattern equal a b} equal a b ==> a == b /// We represent an analog of the following Dafny axiom with /// `is_prefix_def_fact`. Our analog uses `is_prefix` instead /// of `Seq#SameUntil`. /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#SameUntil(s0,s1,n) } /// Seq#SameUntil(s0,s1,n) <==> /// (forall j: int :: { Seq#Index(s0,j) } { Seq#Index(s1,j) } /// 0 <= j && j < n ==> Seq#Index(s0,j) == Seq#Index(s1,j))); private let is_prefix_def_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern is_prefix s0 s1} is_prefix s0 s1 <==> length s0 <= length s1 /\ (forall (j: nat).{:pattern index s0 j \/ index s1 j} j < length s0 ==> index s0 j == index s1 j) /// We represent the following Dafny axiom with `take_length_fact`: /// /// axiom (forall<T> s: Seq T, n: int :: { Seq#Length(Seq#Take(s,n)) } /// 0 <= n && n <= Seq#Length(s) ==> Seq#Length(Seq#Take(s,n)) == n); private let take_length_fact = forall (ty: Type u#a) (s: seq ty) (n: nat).{:pattern length (take s n)} n <= length s ==> length (take s n) = n /// We represent the following Dafny axiom with `index_into_take_fact`. /// /// axiom (forall<T> s: Seq T, n: int, j: int :: /// {:weight 25} /// { Seq#Index(Seq#Take(s,n), j) } /// { Seq#Index(s, j), Seq#Take(s,n) } /// 0 <= j && j < n && j < Seq#Length(s) ==> /// Seq#Index(Seq#Take(s,n), j) == Seq#Index(s, j)); private let index_into_take_fact (_ : squash (take_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (n: nat) (j: nat). {:pattern index (take s n) j \/ index s j ; take s n} j < n && n <= length s ==> index (take s n) j == index s j /// We represent the following Dafny axiom with `drop_length_fact`. /// /// axiom (forall<T> s: Seq T, n: int :: { Seq#Length(Seq#Drop(s,n)) } /// 0 <= n && n <= Seq#Length(s) ==> Seq#Length(Seq#Drop(s,n)) == Seq#Length(s) - n); private let drop_length_fact = forall (ty: Type u#a) (s: seq ty) (n: nat). {:pattern length (drop s n)} n <= length s ==> length (drop s n) = length s - n /// We represent the following Dafny axiom with `index_into_drop_fact`. /// /// axiom (forall<T> s: Seq T, n: int, j: int :: /// {:weight 25} /// { Seq#Index(Seq#Drop(s,n), j) } /// 0 <= n && 0 <= j && j < Seq#Length(s)-n ==> /// Seq#Index(Seq#Drop(s,n), j) == Seq#Index(s, j+n)); private let index_into_drop_fact (_ : squash (drop_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (n: nat) (j: nat). {:pattern index (drop s n) j} j < length s - n ==> index (drop s n) j == index s (j + n) /// We represent the following Dafny axiom with `drop_index_offset_fact`. /// /// axiom (forall<T> s: Seq T, n: int, k: int :: /// {:weight 25} /// { Seq#Index(s, k), Seq#Drop(s,n) } /// 0 <= n && n <= k && k < Seq#Length(s) ==> /// Seq#Index(Seq#Drop(s,n), k-n) == Seq#Index(s, k)); private let drop_index_offset_fact (_ : squash (drop_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (n: nat) (k: nat). {:pattern index s k; drop s n} n <= k && k < length s ==> index (drop s n) (k - n) == index s k /// We represent the following Dafny axiom with `append_then_take_or_drop_fact`. /// /// axiom (forall<T> s, t: Seq T, n: int :: /// { Seq#Take(Seq#Append(s, t), n) } /// { Seq#Drop(Seq#Append(s, t), n) } /// n == Seq#Length(s) /// ==> /// Seq#Take(Seq#Append(s, t), n) == s && /// Seq#Drop(Seq#Append(s, t), n) == t); private let append_then_take_or_drop_fact (_ : squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (t: seq ty) (n: nat). {:pattern take (append s t) n \/ drop (append s t) n} n = length s ==> take (append s t) n == s /\ drop (append s t) n == t /// We represent the following Dafny axiom with `take_commutes_with_in_range_update_fact`. /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: /// { Seq#Take(Seq#Update(s, i, v), n) } /// 0 <= i && i < n && n <= Seq#Length(s) ==> /// Seq#Take(Seq#Update(s, i, v), n) == Seq#Update(Seq#Take(s, n), i, v) ); private let take_commutes_with_in_range_update_fact (_ : squash (update_maintains_length_fact u#a /\ take_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (i: nat) (v: ty) (n: nat).{:pattern take (update s i v) n} i < n && n <= length s ==> take (update s i v) n == update (take s n) i v /// We represent the following Dafny axiom with `take_ignores_out_of_range_update_fact`. /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: /// { Seq#Take(Seq#Update(s, i, v), n) } /// n <= i && i < Seq#Length(s) ==> Seq#Take(Seq#Update(s, i, v), n) == Seq#Take(s, n)); private let take_ignores_out_of_range_update_fact (_ : squash (update_maintains_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (i: nat) (v: ty) (n: nat).{:pattern take (update s i v) n} n <= i && i < length s ==> take (update s i v) n == take s n /// We represent the following Dafny axiom with `drop_commutes_with_in_range_update_fact`. /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: /// { Seq#Drop(Seq#Update(s, i, v), n) } /// 0 <= n && n <= i && i < Seq#Length(s) ==> /// Seq#Drop(Seq#Update(s, i, v), n) == Seq#Update(Seq#Drop(s, n), i-n, v) ); private let drop_commutes_with_in_range_update_fact (_ : squash (update_maintains_length_fact u#a /\ drop_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (i: nat) (v: ty) (n: nat).{:pattern drop (update s i v) n} n <= i && i < length s ==> drop (update s i v) n == update (drop s n) (i - n) v /// We represent the following Dafny axiom with `drop_ignores_out_of_range_update_fact`. /// Jay noticed that it was unnecessarily weak, possibly due to a typo, so he reported this as /// Dafny issue #1423 (https://github.com/dafny-lang/dafny/issues/1423) and updated it here. /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: /// { Seq#Drop(Seq#Update(s, i, v), n) } /// 0 <= i && i < n && n < Seq#Length(s) ==> Seq#Drop(Seq#Update(s, i, v), n) == Seq#Drop(s, n)); private let drop_ignores_out_of_range_update_fact (_ : squash (update_maintains_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (i: nat) (v: ty) (n: nat).{:pattern drop (update s i v) n} i < n && n <= length s ==> drop (update s i v) n == drop s n /// We represent the following Dafny axiom with `drop_commutes_with_build_fact`. /// /// axiom (forall<T> s: Seq T, v: T, n: int :: /// { Seq#Drop(Seq#Build(s, v), n) } /// 0 <= n && n <= Seq#Length(s) ==> /// Seq#Drop(Seq#Build(s, v), n) == Seq#Build(Seq#Drop(s, n), v) ); private let drop_commutes_with_build_fact (_ : squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (n: nat).{:pattern drop (build s v) n} n <= length s ==> drop (build s v) n == build (drop s n) v /// We include the definition of `rank` among our facts. private let rank_def_fact = forall (ty: Type u#a) (v: ty).{:pattern rank v} rank v == v /// We represent the following Dafny axiom with `element_ranks_less_fact`. /// /// axiom (forall s: Seq Box, i: int :: /// { DtRank($Unbox(Seq#Index(s, i)): DatatypeType) } /// 0 <= i && i < Seq#Length(s) ==> DtRank($Unbox(Seq#Index(s, i)): DatatypeType) < Seq#Rank(s) );
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val element_ranks_less_fact : Prims.logical
[]
FStar.Sequence.Base.element_ranks_less_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 47, "end_line": 491, "start_col": 2, "start_line": 490 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let build_contains_equiv_fact = forall (ty: Type u#a) (s: seq ty) (v: ty) (x: ty).{:pattern contains (build s v) x} contains (build s v) x <==> (v == x \/ contains s x)
let build_contains_equiv_fact =
false
null
false
forall (ty: Type u#a) (s: seq ty) (v: ty) (x: ty). {:pattern contains (build s v) x} contains (build s v) x <==> (v == x \/ contains s x)
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.l_iff", "FStar.Sequence.Base.contains", "FStar.Sequence.Base.build", "Prims.l_or", "Prims.eq2" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1)); private let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1 /// We represent the following Dafny axiom with `index_into_singleton_fact`: /// /// axiom (forall<T> t: T :: { Seq#Index(Seq#Singleton(t), 0) } Seq#Index(Seq#Singleton(t), 0) == t); private let index_into_singleton_fact (_: squash (singleton_length_one_fact u#a)) = forall (ty: Type u#a) (v: ty).{:pattern index (singleton v) 0} index (singleton v) 0 == v /// We represent the following axiom with `index_after_append_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#Index(Seq#Append(s0,s1), n) } /// (n < Seq#Length(s0) ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s0, n)) && /// (Seq#Length(s0) <= n ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s1, n - Seq#Length(s0)))); private let index_after_append_fact (_: squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty) (n: nat{n < length (append s0 s1)}) .{:pattern index (append s0 s1) n} (n < length s0 ==> index (append s0 s1) n == index s0 n) /\ (length s0 <= n ==> index (append s0 s1) n == index s1 (n - length s0)) /// We represent the following Dafny axiom with `update_maintains_length`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Length(Seq#Update(s,i,v)) } /// 0 <= i && i < Seq#Length(s) ==> Seq#Length(Seq#Update(s,i,v)) == Seq#Length(s)); private let update_maintains_length_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)} length (update s i v) = length s /// We represent the following Dafny axiom with `update_then_index_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: { Seq#Index(Seq#Update(s,i,v),n) } /// 0 <= n && n < Seq#Length(s) ==> /// (i == n ==> Seq#Index(Seq#Update(s,i,v),n) == v) && /// (i != n ==> Seq#Index(Seq#Update(s,i,v),n) == Seq#Index(s,n))); private let update_then_index_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty) (n: nat{n < length (update s i v)}) .{:pattern index (update s i v) n} n < length s ==> (i = n ==> index (update s i v) n == v) /\ (i <> n ==> index (update s i v) n == index s n) /// We represent the following Dafny axiom with `contains_iff_exists_index_fact`: /// /// axiom (forall<T> s: Seq T, x: T :: { Seq#Contains(s,x) } /// Seq#Contains(s,x) <==> /// (exists i: int :: { Seq#Index(s,i) } 0 <= i && i < Seq#Length(s) && Seq#Index(s,i) == x)); private let contains_iff_exists_index_fact = forall (ty: Type u#a) (s: seq ty) (x: ty).{:pattern contains s x} contains s x <==> (exists (i: nat).{:pattern index s i} i < length s /\ index s i == x) /// We represent the following Dafny axiom with `empty_doesnt_contain_fact`: /// /// axiom (forall<T> x: T :: /// { Seq#Contains(Seq#Empty(), x) } /// !Seq#Contains(Seq#Empty(), x)); private let empty_doesnt_contain_anything_fact = forall (ty: Type u#a) (x: ty).{:pattern contains empty x} ~(contains empty x) /// We represent the following Dafny axiom with `build_contains_equiv_fact`: /// /// axiom (forall<T> s: Seq T, v: T, x: T :: // needed to prove things like '4 in [2,3,4]', see method TestSequences0 in SmallTests.dfy /// { Seq#Contains(Seq#Build(s, v), x) } /// Seq#Contains(Seq#Build(s, v), x) <==> (v == x || Seq#Contains(s, x)));
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val build_contains_equiv_fact : Prims.logical
[]
FStar.Sequence.Base.build_contains_equiv_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 56, "end_line": 275, "start_col": 2, "start_line": 274 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_maintains_length_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)} length (update s i v) = length s
let update_maintains_length_fact =
false
null
false
forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty). {:pattern length (update s i v)} length (update s i v) = length s
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Sequence.Base.length", "Prims.op_Equality", "FStar.Sequence.Base.update" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1)); private let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1 /// We represent the following Dafny axiom with `index_into_singleton_fact`: /// /// axiom (forall<T> t: T :: { Seq#Index(Seq#Singleton(t), 0) } Seq#Index(Seq#Singleton(t), 0) == t); private let index_into_singleton_fact (_: squash (singleton_length_one_fact u#a)) = forall (ty: Type u#a) (v: ty).{:pattern index (singleton v) 0} index (singleton v) 0 == v /// We represent the following axiom with `index_after_append_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#Index(Seq#Append(s0,s1), n) } /// (n < Seq#Length(s0) ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s0, n)) && /// (Seq#Length(s0) <= n ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s1, n - Seq#Length(s0)))); private let index_after_append_fact (_: squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty) (n: nat{n < length (append s0 s1)}) .{:pattern index (append s0 s1) n} (n < length s0 ==> index (append s0 s1) n == index s0 n) /\ (length s0 <= n ==> index (append s0 s1) n == index s1 (n - length s0)) /// We represent the following Dafny axiom with `update_maintains_length`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Length(Seq#Update(s,i,v)) } /// 0 <= i && i < Seq#Length(s) ==> Seq#Length(Seq#Update(s,i,v)) == Seq#Length(s));
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_maintains_length_fact : Prims.logical
[]
FStar.Sequence.Base.update_maintains_length_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 36, "end_line": 232, "start_col": 2, "start_line": 231 }
Prims.Tot
[ { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Sequence", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let take_contains_equiv_exists_fact = forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty).{:pattern contains (take s n) x} contains (take s n) x <==> (exists (i: nat).{:pattern index s i} i < n /\ i < length s /\ index s i == x)
let take_contains_equiv_exists_fact =
false
null
false
forall (ty: Type u#a) (s: seq ty) (n: nat{n <= length s}) (x: ty). {:pattern contains (take s n) x} contains (take s n) x <==> (exists (i: nat). {:pattern index s i} i < n /\ i < length s /\ index s i == x)
{ "checked_file": "FStar.Sequence.Base.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "FStar.Sequence.Base.fsti" }
[ "total" ]
[ "Prims.l_Forall", "FStar.Sequence.Base.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.Sequence.Base.length", "Prims.l_iff", "FStar.Sequence.Base.contains", "FStar.Sequence.Base.take", "Prims.l_Exists", "Prims.l_and", "Prims.op_LessThan", "Prims.eq2", "FStar.Sequence.Base.index" ]
[]
(* Copyright 2008-2021 Jay Lorch, Rustan Leino, Alex Summers, Dan Rosen, Nikhil Swamy, Microsoft Research, and contributors to the Dafny Project 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. Includes material from the Dafny project (https://github.com/dafny-lang/dafny) which carries this license information: Created 9 February 2008 by Rustan Leino. Converted to Boogie 2 on 28 June 2008. Edited sequence axioms 20 October 2009 by Alex Summers. Modified 2014 by Dan Rosen. Copyright (c) 2008-2014, Microsoft. Copyright by the contributors to the Dafny Project SPDX-License-Identifier: MIT *) (** This module declares a type and functions used for modeling sequences as they're modeled in Dafny. @summary Type and functions for modeling sequences *) module FStar.Sequence.Base new val seq ([@@@ strictly_positive] a: Type u#a) : Type u#a (** We translate each Dafny sequence function prefixed with `Seq#` into an F* function. **) /// We represent the Dafny function `Seq#Length` with `length`: /// /// function Seq#Length<T>(Seq T): int; val length : #ty: Type -> seq ty -> nat /// We represent the Dafny function `Seq#Empty` with `empty`: /// /// function Seq#Empty<T>(): Seq T; /// /// We also provide an alias `nil` for it. val empty : #ty: Type -> seq ty /// We represent the Dafny function `Seq#Singleton` with `singleton`: /// /// function Seq#Singleton<T>(T): Seq T; val singleton : #ty: Type -> ty -> seq ty /// We represent the Dafny function `Seq#Index` with `index`: /// /// function Seq#Index<T>(Seq T, int): T; /// /// We also provide the infix symbol `$@` for it. val index: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty let ($@) = index /// We represent the Dafny function `Seq#Build` with `build`: /// /// function Seq#Build<T>(s: Seq T, val: T): Seq T; /// /// We also provide the infix symbol `$::` for it. val build: #ty: Type -> seq ty -> ty -> seq ty let ($::) = build /// We represent the Dafny function `Seq#Append` with `append`: /// /// function Seq#Append<T>(Seq T, Seq T): Seq T; /// /// We also provide the infix notation `$+` for it. val append: #ty: Type -> seq ty -> seq ty -> seq ty let ($+) = append /// We represent the Dafny function `Seq#Update` with `update`: /// /// function Seq#Update<T>(Seq T, int, T): Seq T; val update: #ty: Type -> s: seq ty -> i: nat{i < length s} -> ty -> seq ty /// We represent the Dafny function `Seq#Contains` with `contains`: /// /// function Seq#Contains<T>(Seq T, T): bool; val contains: #ty: Type -> seq ty -> ty -> Type0 /// We represent the Dafny function `Seq#Take` with `take`: /// /// function Seq#Take<T>(s: Seq T, howMany: int): Seq T; val take: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Drop` with `drop`: /// /// function Seq#Drop<T>(s: Seq T, howMany: int): Seq T; val drop: #ty: Type -> s: seq ty -> howMany: nat{howMany <= length s} -> seq ty /// We represent the Dafny function `Seq#Equal` with `equal`. /// /// function Seq#Equal<T>(Seq T, Seq T): bool; /// /// We also provide the infix symbol `$==` for it. val equal: #ty: Type -> seq ty -> seq ty -> Type0 let ($==) = equal /// Instead of representing the Dafny function `Seq#SameUntil`, which /// is only ever used in Dafny to represent prefix relations, we /// instead use `is_prefix`. /// /// function Seq#SameUntil<T>(Seq T, Seq T, int): bool; /// /// We also provide the infix notation `$<=` for it. val is_prefix: #ty: Type -> seq ty -> seq ty -> Type0 let ($<=) = is_prefix /// We represent the Dafny function `Seq#Rank` with `rank`. /// /// function Seq#Rank<T>(Seq T): int; val rank: #ty: Type -> ty -> ty (** We translate each sequence axiom from the Dafny prelude into an F* predicate ending in `_fact`. **) /// We don't need the following axiom since we return a nat from length: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } 0 <= Seq#Length(s)); /// We represent the following Dafny axiom with `length_of_empty_is_zero_fact`: /// /// axiom (forall<T> :: { Seq#Empty(): Seq T } Seq#Length(Seq#Empty(): Seq T) == 0); private let length_of_empty_is_zero_fact = forall (ty: Type u#a).{:pattern empty #ty} length (empty #ty) = 0 /// We represent the following Dafny axiom with `length_zero_implies_empty_fact`: /// /// axiom (forall<T> s: Seq T :: { Seq#Length(s) } /// (Seq#Length(s) == 0 ==> s == Seq#Empty()) private let length_zero_implies_empty_fact = forall (ty: Type u#a) (s: seq ty).{:pattern length s} length s = 0 ==> s == empty /// We represent the following Dafny axiom with `singleton_length_one_fact`: /// /// axiom (forall<T> t: T :: { Seq#Length(Seq#Singleton(t)) } Seq#Length(Seq#Singleton(t)) == 1); private let singleton_length_one_fact = forall (ty: Type u#a) (v: ty).{:pattern length (singleton v)} length (singleton v) = 1 /// We represent the following Dafny axiom with `build_increments_length_fact`: /// /// axiom (forall<T> s: Seq T, v: T :: /// { Seq#Build(s,v) } /// Seq#Length(Seq#Build(s,v)) == 1 + Seq#Length(s)); private let build_increments_length_fact = forall (ty: Type u#a) (s: seq ty) (v: ty).{:pattern build s v} length (build s v) = 1 + length s /// We represent the following Dafny axiom with `index_into_build_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Index(Seq#Build(s,v), i) } /// (i == Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == v) && /// (i != Seq#Length(s) ==> Seq#Index(Seq#Build(s,v), i) == Seq#Index(s, i))); private let index_into_build_fact (_: squash (build_increments_length_fact u#a)) = forall (ty: Type u#a) (s: seq ty) (v: ty) (i: nat{i < length (build s v)}) .{:pattern index (build s v) i} (i = length s ==> index (build s v) i == v) /\ (i <> length s ==> index (build s v) i == index s i) /// We represent the following Dafny axiom with `append_sums_lengths_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T :: { Seq#Length(Seq#Append(s0,s1)) } /// Seq#Length(Seq#Append(s0,s1)) == Seq#Length(s0) + Seq#Length(s1)); private let append_sums_lengths_fact = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty).{:pattern length (append s0 s1)} length (append s0 s1) = length s0 + length s1 /// We represent the following Dafny axiom with `index_into_singleton_fact`: /// /// axiom (forall<T> t: T :: { Seq#Index(Seq#Singleton(t), 0) } Seq#Index(Seq#Singleton(t), 0) == t); private let index_into_singleton_fact (_: squash (singleton_length_one_fact u#a)) = forall (ty: Type u#a) (v: ty).{:pattern index (singleton v) 0} index (singleton v) 0 == v /// We represent the following axiom with `index_after_append_fact`: /// /// axiom (forall<T> s0: Seq T, s1: Seq T, n: int :: { Seq#Index(Seq#Append(s0,s1), n) } /// (n < Seq#Length(s0) ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s0, n)) && /// (Seq#Length(s0) <= n ==> Seq#Index(Seq#Append(s0,s1), n) == Seq#Index(s1, n - Seq#Length(s0)))); private let index_after_append_fact (_: squash (append_sums_lengths_fact u#a)) = forall (ty: Type u#a) (s0: seq ty) (s1: seq ty) (n: nat{n < length (append s0 s1)}) .{:pattern index (append s0 s1) n} (n < length s0 ==> index (append s0 s1) n == index s0 n) /\ (length s0 <= n ==> index (append s0 s1) n == index s1 (n - length s0)) /// We represent the following Dafny axiom with `update_maintains_length`: /// /// axiom (forall<T> s: Seq T, i: int, v: T :: { Seq#Length(Seq#Update(s,i,v)) } /// 0 <= i && i < Seq#Length(s) ==> Seq#Length(Seq#Update(s,i,v)) == Seq#Length(s)); private let update_maintains_length_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty).{:pattern length (update s i v)} length (update s i v) = length s /// We represent the following Dafny axiom with `update_then_index_fact`: /// /// axiom (forall<T> s: Seq T, i: int, v: T, n: int :: { Seq#Index(Seq#Update(s,i,v),n) } /// 0 <= n && n < Seq#Length(s) ==> /// (i == n ==> Seq#Index(Seq#Update(s,i,v),n) == v) && /// (i != n ==> Seq#Index(Seq#Update(s,i,v),n) == Seq#Index(s,n))); private let update_then_index_fact = forall (ty: Type u#a) (s: seq ty) (i: nat{i < length s}) (v: ty) (n: nat{n < length (update s i v)}) .{:pattern index (update s i v) n} n < length s ==> (i = n ==> index (update s i v) n == v) /\ (i <> n ==> index (update s i v) n == index s n) /// We represent the following Dafny axiom with `contains_iff_exists_index_fact`: /// /// axiom (forall<T> s: Seq T, x: T :: { Seq#Contains(s,x) } /// Seq#Contains(s,x) <==> /// (exists i: int :: { Seq#Index(s,i) } 0 <= i && i < Seq#Length(s) && Seq#Index(s,i) == x)); private let contains_iff_exists_index_fact = forall (ty: Type u#a) (s: seq ty) (x: ty).{:pattern contains s x} contains s x <==> (exists (i: nat).{:pattern index s i} i < length s /\ index s i == x) /// We represent the following Dafny axiom with `empty_doesnt_contain_fact`: /// /// axiom (forall<T> x: T :: /// { Seq#Contains(Seq#Empty(), x) } /// !Seq#Contains(Seq#Empty(), x)); private let empty_doesnt_contain_anything_fact = forall (ty: Type u#a) (x: ty).{:pattern contains empty x} ~(contains empty x) /// We represent the following Dafny axiom with `build_contains_equiv_fact`: /// /// axiom (forall<T> s: Seq T, v: T, x: T :: // needed to prove things like '4 in [2,3,4]', see method TestSequences0 in SmallTests.dfy /// { Seq#Contains(Seq#Build(s, v), x) } /// Seq#Contains(Seq#Build(s, v), x) <==> (v == x || Seq#Contains(s, x))); private let build_contains_equiv_fact = forall (ty: Type u#a) (s: seq ty) (v: ty) (x: ty).{:pattern contains (build s v) x} contains (build s v) x <==> (v == x \/ contains s x) /// We represent the following Dafny axiom with `take_contains_equiv_exists_fact`: /// /// axiom (forall<T> s: Seq T, n: int, x: T :: /// { Seq#Contains(Seq#Take(s, n), x) } /// Seq#Contains(Seq#Take(s, n), x) <==> /// (exists i: int :: { Seq#Index(s, i) } /// 0 <= i && i < n && i < Seq#Length(s) && Seq#Index(s, i) == x));
false
true
FStar.Sequence.Base.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": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val take_contains_equiv_exists_fact : Prims.logical
[]
FStar.Sequence.Base.take_contains_equiv_exists_fact
{ "file_name": "ulib/experimental/FStar.Sequence.Base.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
Prims.logical
{ "end_col": 82, "end_line": 288, "start_col": 2, "start_line": 286 }