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 table_inv_precomp (#a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (k: concrete_ops a_t len ctx_len) (l: size_window_t a_t len) (table_len: table_len_t len) : table_inv_t a_t len table_len
[ { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let table_inv_precomp (#a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) : table_inv_t a_t len table_len = fun a table -> 1 < v table_len /\ v table_len = pow2 (v l) /\ (forall (j:nat{j < v table_len}). PT.precomp_table_inv len ctx_len k a table_len table j)
val table_inv_precomp (#a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (k: concrete_ops a_t len ctx_len) (l: size_window_t a_t len) (table_len: table_len_t len) : table_inv_t a_t len table_len let table_inv_precomp (#a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (k: concrete_ops a_t len ctx_len) (l: size_window_t a_t len) (table_len: table_len_t len) : table_inv_t a_t len table_len =
false
null
false
fun a table -> 1 < v table_len /\ v table_len = pow2 (v l) /\ (forall (j: nat{j < v table_len}). PT.precomp_table_inv len ctx_len k a table_len table j)
{ "checked_file": "Hacl.Impl.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Exponentiation.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.Exponentiation.size_window_t", "Hacl.Impl.Exponentiation.table_len_t", "Lib.Sequence.lseq", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Star_Bang", "Prims.l_and", "Prims.op_LessThan", "Prims.op_Equality", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.pow2", "Prims.l_Forall", "Prims.nat", "Hacl.Impl.PrecompTable.precomp_table_inv", "Hacl.Impl.Exponentiation.table_inv_t" ]
[]
module Hacl.Impl.Exponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Lib.Exponentiation module BD = Hacl.Bignum.Definitions module PT = Hacl.Impl.PrecompTable include Hacl.Impl.Exponentiation.Definitions #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // This function computes `a^b` using a binary right-to-left method // It takes variable time to compute the result inline_for_extraction noextract val lexp_rl_vartime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint b res /\ disjoint a b /\ disjoint ctx a /\ disjoint ctx res /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_rl #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) // This function computes `a^b` using Montgomery's ladder (a binary method) // It takes constant time to compute the result inline_for_extraction noextract val lexp_mont_ladder_swap_consttime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint b res /\ disjoint a b /\ disjoint ctx a /\ disjoint ctx res /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_mont_ladder_swap #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) // This function computes `a^(2^b)` and writes the result in `res` inline_for_extraction noextract val lexp_pow2: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> b:size_t -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h res /\ live h ctx /\ live h a /\ disjoint res ctx /\ disjoint a ctx /\ disjoint a res /\ k.to.linv (as_seq h a) /\ k.to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_pow2 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v b)) // This function computes `a^(2^b)` and writes the result in `a` inline_for_extraction noextract val lexp_pow2_in_place: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> b:size_t -> Stack unit (requires fun h -> live h a /\ live h ctx /\ disjoint a ctx /\ k.to.linv (as_seq h a) /\ k.to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ k.to.linv (as_seq h1 a) /\ k.to.refl (as_seq h1 a) == S.exp_pow2 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v b)) // Fixed-window method using a precomputed table //---------------------------------------------- inline_for_extraction noextract let size_window_t (a_t:inttype_a) (len:size_t{v len > 0}) = l:size_t{0 < v l /\ v l < bits a_t /\ v l < 32 /\ pow2 (v l) * v len <= max_size_t} inline_for_extraction noextract let table_len_t (len:size_t{v len > 0}) = table_len:size_t{v table_len * v len <= max_size_t} inline_for_extraction noextract let table_inv_t (a_t:inttype_a) (len:size_t{v len > 0}) (table_len:table_len_t len) = a:LSeq.lseq (uint_t a_t SEC) (v len) -> table:LSeq.lseq (uint_t a_t SEC) (v (table_len *! len)) -> GTot Type0 inline_for_extraction noextract let pow_a_to_small_b_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) (table_inv:table_inv_t a_t len table_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:Ghost.erased (LSeq.lseq (uint_t a_t SEC) (v len)) -> table:clbuffer (uint_t a_t SEC) (table_len *! len) -> b:uint_t a_t SEC{v b < pow2 (v l)} -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h table /\ live h res /\ live h ctx /\ disjoint table res /\ disjoint ctx res /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv a /\ table_inv a (as_seq h table)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.pow k.to.comm_monoid (k.to.refl a) (v b)) inline_for_extraction noextract let lexp_fw_table_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) (table_inv:table_inv_t a_t len table_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> table:clbuffer (uint_t a_t SEC) (table_len *! len) -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ live h table /\ disjoint a res /\ disjoint a ctx /\ disjoint b res /\ disjoint res ctx /\ disjoint res table /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a) /\ table_inv (as_seq h a) (as_seq h table)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_fw k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l)) inline_for_extraction noextract val mk_lexp_fw_table: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> l:size_window_t a_t len -> table_len:table_len_t len -> table_inv:table_inv_t a_t len table_len -> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv -> lexp_fw_table_st a_t len ctx_len k l table_len table_inv // Fixed-window method with a precomputed // table = [a^0 = one; a^1; a^2; ..; a^(table_len - 1)] //----------------------------------------------------- inline_for_extraction noextract let table_inv_precomp (#a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len)
false
false
Hacl.Impl.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val table_inv_precomp (#a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (k: concrete_ops a_t len ctx_len) (l: size_window_t a_t len) (table_len: table_len_t len) : table_inv_t a_t len table_len
[]
Hacl.Impl.Exponentiation.table_inv_precomp
{ "file_name": "code/bignum/Hacl.Impl.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len -> l: Hacl.Impl.Exponentiation.size_window_t a_t len -> table_len: Hacl.Impl.Exponentiation.table_len_t len -> Hacl.Impl.Exponentiation.table_inv_t a_t len table_len
{ "end_col": 61, "end_line": 215, "start_col": 2, "start_line": 212 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lexp_fw_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint a ctx /\ disjoint b res /\ disjoint res ctx /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_fw #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l))
let lexp_fw_st (a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (k: concrete_ops a_t len ctx_len) (l: size_window_t a_t len) =
false
null
false
ctx: lbuffer (uint_t a_t SEC) ctx_len -> a: lbuffer (uint_t a_t SEC) len -> bLen: size_t -> bBits: size_t{(v bBits - 1) / bits a_t < v bLen} -> b: lbuffer (uint_t a_t SEC) bLen -> res: lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint a ctx /\ disjoint b res /\ disjoint res ctx /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_fw #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l))
{ "checked_file": "Hacl.Impl.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Exponentiation.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.Exponentiation.size_window_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.op_LessThan", "Prims.op_Division", "Prims.op_Subtraction", "Lib.IntTypes.bits", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Hacl.Bignum.Definitions.bn_v", "Prims.pow2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv_ctx", "FStar.Ghost.reveal", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__to", "Lib.Buffer.as_seq", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.exp_fw", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid" ]
[]
module Hacl.Impl.Exponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Lib.Exponentiation module BD = Hacl.Bignum.Definitions module PT = Hacl.Impl.PrecompTable include Hacl.Impl.Exponentiation.Definitions #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // This function computes `a^b` using a binary right-to-left method // It takes variable time to compute the result inline_for_extraction noextract val lexp_rl_vartime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint b res /\ disjoint a b /\ disjoint ctx a /\ disjoint ctx res /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_rl #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) // This function computes `a^b` using Montgomery's ladder (a binary method) // It takes constant time to compute the result inline_for_extraction noextract val lexp_mont_ladder_swap_consttime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint b res /\ disjoint a b /\ disjoint ctx a /\ disjoint ctx res /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_mont_ladder_swap #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) // This function computes `a^(2^b)` and writes the result in `res` inline_for_extraction noextract val lexp_pow2: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> b:size_t -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h res /\ live h ctx /\ live h a /\ disjoint res ctx /\ disjoint a ctx /\ disjoint a res /\ k.to.linv (as_seq h a) /\ k.to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_pow2 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v b)) // This function computes `a^(2^b)` and writes the result in `a` inline_for_extraction noextract val lexp_pow2_in_place: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> b:size_t -> Stack unit (requires fun h -> live h a /\ live h ctx /\ disjoint a ctx /\ k.to.linv (as_seq h a) /\ k.to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ k.to.linv (as_seq h1 a) /\ k.to.refl (as_seq h1 a) == S.exp_pow2 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v b)) // Fixed-window method using a precomputed table //---------------------------------------------- inline_for_extraction noextract let size_window_t (a_t:inttype_a) (len:size_t{v len > 0}) = l:size_t{0 < v l /\ v l < bits a_t /\ v l < 32 /\ pow2 (v l) * v len <= max_size_t} inline_for_extraction noextract let table_len_t (len:size_t{v len > 0}) = table_len:size_t{v table_len * v len <= max_size_t} inline_for_extraction noextract let table_inv_t (a_t:inttype_a) (len:size_t{v len > 0}) (table_len:table_len_t len) = a:LSeq.lseq (uint_t a_t SEC) (v len) -> table:LSeq.lseq (uint_t a_t SEC) (v (table_len *! len)) -> GTot Type0 inline_for_extraction noextract let pow_a_to_small_b_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) (table_inv:table_inv_t a_t len table_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:Ghost.erased (LSeq.lseq (uint_t a_t SEC) (v len)) -> table:clbuffer (uint_t a_t SEC) (table_len *! len) -> b:uint_t a_t SEC{v b < pow2 (v l)} -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h table /\ live h res /\ live h ctx /\ disjoint table res /\ disjoint ctx res /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv a /\ table_inv a (as_seq h table)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.pow k.to.comm_monoid (k.to.refl a) (v b)) inline_for_extraction noextract let lexp_fw_table_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) (table_inv:table_inv_t a_t len table_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> table:clbuffer (uint_t a_t SEC) (table_len *! len) -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ live h table /\ disjoint a res /\ disjoint a ctx /\ disjoint b res /\ disjoint res ctx /\ disjoint res table /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a) /\ table_inv (as_seq h a) (as_seq h table)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_fw k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l)) inline_for_extraction noextract val mk_lexp_fw_table: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> l:size_window_t a_t len -> table_len:table_len_t len -> table_inv:table_inv_t a_t len table_len -> pow_a_to_small_b:pow_a_to_small_b_st a_t len ctx_len k l table_len table_inv -> lexp_fw_table_st a_t len ctx_len k l table_len table_inv // Fixed-window method with a precomputed // table = [a^0 = one; a^1; a^2; ..; a^(table_len - 1)] //----------------------------------------------------- inline_for_extraction noextract let table_inv_precomp (#a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) : table_inv_t a_t len table_len = fun a table -> 1 < v table_len /\ v table_len = pow2 (v l) /\ (forall (j:nat{j < v table_len}). PT.precomp_table_inv len ctx_len k a table_len table j) // This function returns table.[bits_l] = a^bits_l // It takes variable time to access bits_l-th element of a table inline_for_extraction noextract val lprecomp_get_vartime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> l:size_window_t a_t len -> table_len:table_len_t len -> pow_a_to_small_b_st a_t len ctx_len k l table_len (table_inv_precomp len ctx_len k l table_len) // This function returns table.[bits_l] = a^bits_l // It takes constant time to access bits_l-th element of a table inline_for_extraction noextract val lprecomp_get_consttime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> l:size_window_t a_t len -> table_len:table_len_t len -> pow_a_to_small_b_st a_t len ctx_len k l table_len (table_inv_precomp len ctx_len k l table_len) inline_for_extraction noextract let lexp_fw_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len)
false
false
Hacl.Impl.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lexp_fw_st : a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len -> l: Hacl.Impl.Exponentiation.size_window_t a_t len -> Type0
[]
Hacl.Impl.Exponentiation.lexp_fw_st
{ "file_name": "code/bignum/Hacl.Impl.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len -> l: Hacl.Impl.Exponentiation.size_window_t a_t len -> Type0
{ "end_col": 100, "end_line": 270, "start_col": 4, "start_line": 253 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pow_a_to_small_b_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) (table_inv:table_inv_t a_t len table_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:Ghost.erased (LSeq.lseq (uint_t a_t SEC) (v len)) -> table:clbuffer (uint_t a_t SEC) (table_len *! len) -> b:uint_t a_t SEC{v b < pow2 (v l)} -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h table /\ live h res /\ live h ctx /\ disjoint table res /\ disjoint ctx res /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv a /\ table_inv a (as_seq h table)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.pow k.to.comm_monoid (k.to.refl a) (v b))
let pow_a_to_small_b_st (a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (k: concrete_ops a_t len ctx_len) (l: size_window_t a_t len) (table_len: table_len_t len) (table_inv: table_inv_t a_t len table_len) =
false
null
false
ctx: lbuffer (uint_t a_t SEC) ctx_len -> a: Ghost.erased (LSeq.lseq (uint_t a_t SEC) (v len)) -> table: clbuffer (uint_t a_t SEC) (table_len *! len) -> b: uint_t a_t SEC {v b < pow2 (v l)} -> res: lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h table /\ live h res /\ live h ctx /\ disjoint table res /\ disjoint ctx res /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv a /\ table_inv a (as_seq h table)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.pow k.to.comm_monoid (k.to.refl a) (v b))
{ "checked_file": "Hacl.Impl.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Exponentiation.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.Exponentiation.size_window_t", "Hacl.Impl.Exponentiation.table_len_t", "Hacl.Impl.Exponentiation.table_inv_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "FStar.Ghost.erased", "Lib.Sequence.lseq", "Lib.Buffer.clbuffer", "Lib.IntTypes.op_Star_Bang", "Prims.op_LessThan", "Prims.pow2", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.CONST", "Lib.Buffer.MUT", "Lib.Buffer.disjoint", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv_ctx", "FStar.Ghost.reveal", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__to", "Lib.Buffer.as_seq", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.Definition.pow", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid" ]
[]
module Hacl.Impl.Exponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Lib.Exponentiation module BD = Hacl.Bignum.Definitions module PT = Hacl.Impl.PrecompTable include Hacl.Impl.Exponentiation.Definitions #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // This function computes `a^b` using a binary right-to-left method // It takes variable time to compute the result inline_for_extraction noextract val lexp_rl_vartime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint b res /\ disjoint a b /\ disjoint ctx a /\ disjoint ctx res /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_rl #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) // This function computes `a^b` using Montgomery's ladder (a binary method) // It takes constant time to compute the result inline_for_extraction noextract val lexp_mont_ladder_swap_consttime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint b res /\ disjoint a b /\ disjoint ctx a /\ disjoint ctx res /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_mont_ladder_swap #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) // This function computes `a^(2^b)` and writes the result in `res` inline_for_extraction noextract val lexp_pow2: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> b:size_t -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h res /\ live h ctx /\ live h a /\ disjoint res ctx /\ disjoint a ctx /\ disjoint a res /\ k.to.linv (as_seq h a) /\ k.to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_pow2 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v b)) // This function computes `a^(2^b)` and writes the result in `a` inline_for_extraction noextract val lexp_pow2_in_place: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> b:size_t -> Stack unit (requires fun h -> live h a /\ live h ctx /\ disjoint a ctx /\ k.to.linv (as_seq h a) /\ k.to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ k.to.linv (as_seq h1 a) /\ k.to.refl (as_seq h1 a) == S.exp_pow2 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v b)) // Fixed-window method using a precomputed table //---------------------------------------------- inline_for_extraction noextract let size_window_t (a_t:inttype_a) (len:size_t{v len > 0}) = l:size_t{0 < v l /\ v l < bits a_t /\ v l < 32 /\ pow2 (v l) * v len <= max_size_t} inline_for_extraction noextract let table_len_t (len:size_t{v len > 0}) = table_len:size_t{v table_len * v len <= max_size_t} inline_for_extraction noextract let table_inv_t (a_t:inttype_a) (len:size_t{v len > 0}) (table_len:table_len_t len) = a:LSeq.lseq (uint_t a_t SEC) (v len) -> table:LSeq.lseq (uint_t a_t SEC) (v (table_len *! len)) -> GTot Type0 inline_for_extraction noextract let pow_a_to_small_b_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len)
false
false
Hacl.Impl.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val pow_a_to_small_b_st : a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len -> l: Hacl.Impl.Exponentiation.size_window_t a_t len -> table_len: Hacl.Impl.Exponentiation.table_len_t len -> table_inv: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> Type0
[]
Hacl.Impl.Exponentiation.pow_a_to_small_b_st
{ "file_name": "code/bignum/Hacl.Impl.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len -> l: Hacl.Impl.Exponentiation.size_window_t a_t len -> table_len: Hacl.Impl.Exponentiation.table_len_t len -> table_inv: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> Type0
{ "end_col": 76, "end_line": 154, "start_col": 4, "start_line": 141 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.Exponentiation.Definitions", "short_module": null }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "S" }, { "abbrev": true, "full_module": "Lib.Sequence", "short_module": "LSeq" }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lexp_fw_table_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) (table_inv:table_inv_t a_t len table_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> table:clbuffer (uint_t a_t SEC) (table_len *! len) -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ live h table /\ disjoint a res /\ disjoint a ctx /\ disjoint b res /\ disjoint res ctx /\ disjoint res table /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a) /\ table_inv (as_seq h a) (as_seq h table)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_fw k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l))
let lexp_fw_table_st (a_t: inttype_a) (len: size_t{v len > 0}) (ctx_len: size_t) (k: concrete_ops a_t len ctx_len) (l: size_window_t a_t len) (table_len: table_len_t len) (table_inv: table_inv_t a_t len table_len) =
false
null
false
ctx: lbuffer (uint_t a_t SEC) ctx_len -> a: lbuffer (uint_t a_t SEC) len -> bLen: size_t -> bBits: size_t{(v bBits - 1) / bits a_t < v bLen} -> b: lbuffer (uint_t a_t SEC) bLen -> table: clbuffer (uint_t a_t SEC) (table_len *! len) -> res: lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ live h table /\ disjoint a res /\ disjoint a ctx /\ disjoint b res /\ disjoint res ctx /\ disjoint res table /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a) /\ table_inv (as_seq h a) (as_seq h table)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_fw k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b) (v l))
{ "checked_file": "Hacl.Impl.Exponentiation.fsti.checked", "dependencies": [ "prims.fst.checked", "Lib.Sequence.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.Exponentiation.Definitions.fst.checked", "Hacl.Bignum.Definitions.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked", "FStar.Ghost.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Exponentiation.fsti" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.Definitions.inttype_a", "Lib.IntTypes.size_t", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.Exponentiation.size_window_t", "Hacl.Impl.Exponentiation.table_len_t", "Hacl.Impl.Exponentiation.table_inv_t", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.SEC", "Prims.op_LessThan", "Prims.op_Division", "Prims.op_Subtraction", "Lib.IntTypes.bits", "Lib.Buffer.clbuffer", "Lib.IntTypes.op_Star_Bang", "Prims.unit", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Lib.Buffer.live", "Lib.Buffer.MUT", "Lib.Buffer.CONST", "Lib.Buffer.disjoint", "Hacl.Bignum.Definitions.bn_v", "Prims.pow2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv_ctx", "FStar.Ghost.reveal", "Hacl.Impl.Exponentiation.Definitions.to_comm_monoid", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkconcrete_ops__item__to", "Lib.Buffer.as_seq", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__linv", "Lib.Buffer.modifies", "Lib.Buffer.loc", "Prims.eq2", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__a_spec", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__refl", "Lib.Exponentiation.exp_fw", "Hacl.Impl.Exponentiation.Definitions.__proj__Mkto_comm_monoid__item__comm_monoid" ]
[]
module Hacl.Impl.Exponentiation open FStar.HyperStack open FStar.HyperStack.ST open FStar.Mul open Lib.IntTypes open Lib.Buffer module ST = FStar.HyperStack.ST module LSeq = Lib.Sequence module S = Lib.Exponentiation module BD = Hacl.Bignum.Definitions module PT = Hacl.Impl.PrecompTable include Hacl.Impl.Exponentiation.Definitions #reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" // This function computes `a^b` using a binary right-to-left method // It takes variable time to compute the result inline_for_extraction noextract val lexp_rl_vartime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint b res /\ disjoint a b /\ disjoint ctx a /\ disjoint ctx res /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_rl #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) // This function computes `a^b` using Montgomery's ladder (a binary method) // It takes constant time to compute the result inline_for_extraction noextract val lexp_mont_ladder_swap_consttime: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> bLen:size_t -> bBits:size_t{(v bBits - 1) / bits a_t < v bLen} -> b:lbuffer (uint_t a_t SEC) bLen -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h a /\ live h b /\ live h res /\ live h ctx /\ disjoint a res /\ disjoint b res /\ disjoint a b /\ disjoint ctx a /\ disjoint ctx res /\ BD.bn_v h b < pow2 (v bBits) /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv (as_seq h a)) (ensures fun h0 _ h1 -> modifies (loc a |+| loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_mont_ladder_swap #k.to.a_spec k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v bBits) (BD.bn_v h0 b)) // This function computes `a^(2^b)` and writes the result in `res` inline_for_extraction noextract val lexp_pow2: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> b:size_t -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h res /\ live h ctx /\ live h a /\ disjoint res ctx /\ disjoint a ctx /\ disjoint a res /\ k.to.linv (as_seq h a) /\ k.to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.exp_pow2 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v b)) // This function computes `a^(2^b)` and writes the result in `a` inline_for_extraction noextract val lexp_pow2_in_place: #a_t:inttype_a -> len:size_t{v len > 0} -> ctx_len:size_t -> k:concrete_ops a_t len ctx_len -> ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:lbuffer (uint_t a_t SEC) len -> b:size_t -> Stack unit (requires fun h -> live h a /\ live h ctx /\ disjoint a ctx /\ k.to.linv (as_seq h a) /\ k.to.linv_ctx (as_seq h ctx)) (ensures fun h0 _ h1 -> modifies (loc a) h0 h1 /\ k.to.linv (as_seq h1 a) /\ k.to.refl (as_seq h1 a) == S.exp_pow2 k.to.comm_monoid (k.to.refl (as_seq h0 a)) (v b)) // Fixed-window method using a precomputed table //---------------------------------------------- inline_for_extraction noextract let size_window_t (a_t:inttype_a) (len:size_t{v len > 0}) = l:size_t{0 < v l /\ v l < bits a_t /\ v l < 32 /\ pow2 (v l) * v len <= max_size_t} inline_for_extraction noextract let table_len_t (len:size_t{v len > 0}) = table_len:size_t{v table_len * v len <= max_size_t} inline_for_extraction noextract let table_inv_t (a_t:inttype_a) (len:size_t{v len > 0}) (table_len:table_len_t len) = a:LSeq.lseq (uint_t a_t SEC) (v len) -> table:LSeq.lseq (uint_t a_t SEC) (v (table_len *! len)) -> GTot Type0 inline_for_extraction noextract let pow_a_to_small_b_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len) (table_inv:table_inv_t a_t len table_len) = ctx:lbuffer (uint_t a_t SEC) ctx_len -> a:Ghost.erased (LSeq.lseq (uint_t a_t SEC) (v len)) -> table:clbuffer (uint_t a_t SEC) (table_len *! len) -> b:uint_t a_t SEC{v b < pow2 (v l)} -> res:lbuffer (uint_t a_t SEC) len -> Stack unit (requires fun h -> live h table /\ live h res /\ live h ctx /\ disjoint table res /\ disjoint ctx res /\ k.to.linv_ctx (as_seq h ctx) /\ k.to.linv a /\ table_inv a (as_seq h table)) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ k.to.linv (as_seq h1 res) /\ k.to.refl (as_seq h1 res) == S.pow k.to.comm_monoid (k.to.refl a) (v b)) inline_for_extraction noextract let lexp_fw_table_st (a_t:inttype_a) (len:size_t{v len > 0}) (ctx_len:size_t) (k:concrete_ops a_t len ctx_len) (l:size_window_t a_t len) (table_len:table_len_t len)
false
false
Hacl.Impl.Exponentiation.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 50, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lexp_fw_table_st : a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len -> l: Hacl.Impl.Exponentiation.size_window_t a_t len -> table_len: Hacl.Impl.Exponentiation.table_len_t len -> table_inv: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> Type0
[]
Hacl.Impl.Exponentiation.lexp_fw_table_st
{ "file_name": "code/bignum/Hacl.Impl.Exponentiation.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
a_t: Hacl.Impl.Exponentiation.Definitions.inttype_a -> len: Lib.IntTypes.size_t{Lib.IntTypes.v len > 0} -> ctx_len: Lib.IntTypes.size_t -> k: Hacl.Impl.Exponentiation.Definitions.concrete_ops a_t len ctx_len -> l: Hacl.Impl.Exponentiation.size_window_t a_t len -> table_len: Hacl.Impl.Exponentiation.table_len_t len -> table_inv: Hacl.Impl.Exponentiation.table_inv_t a_t len table_len -> Type0
{ "end_col": 87, "end_line": 184, "start_col": 4, "start_line": 166 }
Prims.Tot
val blake2s:Impl.blake2_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s : Impl.blake2_st Spec.Blake2S Core.M32 = Impl.blake2 #Spec.Blake2S #Core.M32 blake2s_init blake2s_update blake2s_finish
val blake2s:Impl.blake2_st Spec.Blake2S Core.M32 let blake2s:Impl.blake2_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2 #Spec.Blake2S #Core.M32 blake2s_init blake2s_update blake2s_finish
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2s_32.blake2s_init", "Hacl.Blake2s_32.blake2s_update", "Hacl.Blake2s_32.blake2s_finish" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32 let blake2s_init : Impl.blake2_init_st Spec.Blake2S Core.M32 = Impl.blake2_init #Spec.Blake2S #Core.M32 let blake2s_update_key : Impl.blake2_update_key_st Spec.Blake2S Core.M32 = Impl.blake2_update_key #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_multi : Impl.blake2_update_multi_st Spec.Blake2S Core.M32 = Impl.blake2_update_multi #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_last : Impl.blake2_update_last_st Spec.Blake2S Core.M32 = Impl.blake2_update_last #Spec.Blake2S #Core.M32 blake2s_update_block private let blake2s_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2S Core.M32 = Impl.blake2_update_blocks #Spec.Blake2S #Core.M32 blake2s_update_multi blake2s_update_last [@CInline] private let blake2s_update : Impl.blake2_update_st Spec.Blake2S Core.M32 = Impl.blake2_update #Spec.Blake2S #Core.M32 blake2s_update_key blake2s_update_blocks let blake2s_finish : Impl.blake2_finish_st Spec.Blake2S Core.M32 = Impl.blake2_finish #Spec.Blake2S #Core.M32 (* The one-shot hash *) [@@ Comment "Write the BLAKE2s digest of message `d` using key `k` into `output`. @param nn Length of to-be-generated digest with 1 <= `nn` <= 32. @param output Pointer to `nn` bytes of memory where the digest is written to. @param ll Length of the input message. @param d Pointer to `ll` bytes of memory where the input message is read from. @param kk Length of the key. Can be 0. @param k Pointer to `kk` bytes of memory where the key is read from."]
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s:Impl.blake2_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 80, "end_line": 47, "start_col": 2, "start_line": 47 }
Prims.Tot
val blake2s_update_key:Impl.blake2_update_key_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s_update_key : Impl.blake2_update_key_st Spec.Blake2S Core.M32 = Impl.blake2_update_key #Spec.Blake2S #Core.M32 blake2s_update_block
val blake2s_update_key:Impl.blake2_update_key_st Spec.Blake2S Core.M32 let blake2s_update_key:Impl.blake2_update_key_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2_update_key #Spec.Blake2S #Core.M32 blake2s_update_block
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_key", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2s_32.blake2s_update_block" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32 let blake2s_init : Impl.blake2_init_st Spec.Blake2S Core.M32 = Impl.blake2_init #Spec.Blake2S #Core.M32
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s_update_key:Impl.blake2_update_key_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s_update_key
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_key_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 69, "end_line": 17, "start_col": 2, "start_line": 17 }
Prims.Tot
val blake2s_malloc:Impl.blake2_malloc_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s_malloc : Impl.blake2_malloc_st Spec.Blake2S Core.M32 = Impl.blake2_malloc Spec.Blake2S Core.M32
val blake2s_malloc:Impl.blake2_malloc_st Spec.Blake2S Core.M32 let blake2s_malloc:Impl.blake2_malloc_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2_malloc Spec.Blake2S Core.M32
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_malloc", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32 let blake2s_init : Impl.blake2_init_st Spec.Blake2S Core.M32 = Impl.blake2_init #Spec.Blake2S #Core.M32 let blake2s_update_key : Impl.blake2_update_key_st Spec.Blake2S Core.M32 = Impl.blake2_update_key #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_multi : Impl.blake2_update_multi_st Spec.Blake2S Core.M32 = Impl.blake2_update_multi #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_last : Impl.blake2_update_last_st Spec.Blake2S Core.M32 = Impl.blake2_update_last #Spec.Blake2S #Core.M32 blake2s_update_block private let blake2s_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2S Core.M32 = Impl.blake2_update_blocks #Spec.Blake2S #Core.M32 blake2s_update_multi blake2s_update_last [@CInline] private let blake2s_update : Impl.blake2_update_st Spec.Blake2S Core.M32 = Impl.blake2_update #Spec.Blake2S #Core.M32 blake2s_update_key blake2s_update_blocks let blake2s_finish : Impl.blake2_finish_st Spec.Blake2S Core.M32 = Impl.blake2_finish #Spec.Blake2S #Core.M32 (* The one-shot hash *) [@@ Comment "Write the BLAKE2s digest of message `d` using key `k` into `output`. @param nn Length of to-be-generated digest with 1 <= `nn` <= 32. @param output Pointer to `nn` bytes of memory where the digest is written to. @param ll Length of the input message. @param d Pointer to `ll` bytes of memory where the input message is read from. @param kk Length of the key. Can be 0. @param k Pointer to `kk` bytes of memory where the key is read from."] let blake2s : Impl.blake2_st Spec.Blake2S Core.M32 = Impl.blake2 #Spec.Blake2S #Core.M32 blake2s_init blake2s_update blake2s_finish
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s_malloc:Impl.blake2_malloc_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s_malloc
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_malloc_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 42, "end_line": 50, "start_col": 2, "start_line": 50 }
Prims.Tot
val blake2s_update_last:Impl.blake2_update_last_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s_update_last : Impl.blake2_update_last_st Spec.Blake2S Core.M32 = Impl.blake2_update_last #Spec.Blake2S #Core.M32 blake2s_update_block
val blake2s_update_last:Impl.blake2_update_last_st Spec.Blake2S Core.M32 let blake2s_update_last:Impl.blake2_update_last_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2_update_last #Spec.Blake2S #Core.M32 blake2s_update_block
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_last", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2s_32.blake2s_update_block" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32 let blake2s_init : Impl.blake2_init_st Spec.Blake2S Core.M32 = Impl.blake2_init #Spec.Blake2S #Core.M32 let blake2s_update_key : Impl.blake2_update_key_st Spec.Blake2S Core.M32 = Impl.blake2_update_key #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_multi : Impl.blake2_update_multi_st Spec.Blake2S Core.M32 = Impl.blake2_update_multi #Spec.Blake2S #Core.M32 blake2s_update_block
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s_update_last:Impl.blake2_update_last_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s_update_last
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_last_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 70, "end_line": 23, "start_col": 2, "start_line": 23 }
Prims.Tot
val blake2s_init:Impl.blake2_init_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s_init : Impl.blake2_init_st Spec.Blake2S Core.M32 = Impl.blake2_init #Spec.Blake2S #Core.M32
val blake2s_init:Impl.blake2_init_st Spec.Blake2S Core.M32 let blake2s_init:Impl.blake2_init_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2_init #Spec.Blake2S #Core.M32
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_init", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s_init:Impl.blake2_init_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s_init
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_init_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 42, "end_line": 14, "start_col": 2, "start_line": 14 }
Prims.Tot
val blake2s_update_multi:Impl.blake2_update_multi_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s_update_multi : Impl.blake2_update_multi_st Spec.Blake2S Core.M32 = Impl.blake2_update_multi #Spec.Blake2S #Core.M32 blake2s_update_block
val blake2s_update_multi:Impl.blake2_update_multi_st Spec.Blake2S Core.M32 let blake2s_update_multi:Impl.blake2_update_multi_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2_update_multi #Spec.Blake2S #Core.M32 blake2s_update_block
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_multi", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2s_32.blake2s_update_block" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32 let blake2s_init : Impl.blake2_init_st Spec.Blake2S Core.M32 = Impl.blake2_init #Spec.Blake2S #Core.M32 let blake2s_update_key : Impl.blake2_update_key_st Spec.Blake2S Core.M32 = Impl.blake2_update_key #Spec.Blake2S #Core.M32 blake2s_update_block
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s_update_multi:Impl.blake2_update_multi_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s_update_multi
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_multi_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 71, "end_line": 20, "start_col": 2, "start_line": 20 }
Prims.Tot
val blake2s_update_block:Impl.blake2_update_block_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32
val blake2s_update_block:Impl.blake2_update_block_st Spec.Blake2S Core.M32 let blake2s_update_block:Impl.blake2_update_block_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2_update_block #Spec.Blake2S #Core.M32
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_block", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s_update_block:Impl.blake2_update_block_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s_update_block
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_block_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 50, "end_line": 11, "start_col": 2, "start_line": 11 }
Prims.Tot
val blake2s_update:Impl.blake2_update_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s_update : Impl.blake2_update_st Spec.Blake2S Core.M32 = Impl.blake2_update #Spec.Blake2S #Core.M32 blake2s_update_key blake2s_update_blocks
val blake2s_update:Impl.blake2_update_st Spec.Blake2S Core.M32 let blake2s_update:Impl.blake2_update_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2_update #Spec.Blake2S #Core.M32 blake2s_update_key blake2s_update_blocks
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2s_32.blake2s_update_key", "Hacl.Blake2s_32.blake2s_update_blocks" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32 let blake2s_init : Impl.blake2_init_st Spec.Blake2S Core.M32 = Impl.blake2_init #Spec.Blake2S #Core.M32 let blake2s_update_key : Impl.blake2_update_key_st Spec.Blake2S Core.M32 = Impl.blake2_update_key #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_multi : Impl.blake2_update_multi_st Spec.Blake2S Core.M32 = Impl.blake2_update_multi #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_last : Impl.blake2_update_last_st Spec.Blake2S Core.M32 = Impl.blake2_update_last #Spec.Blake2S #Core.M32 blake2s_update_block private let blake2s_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2S Core.M32 = Impl.blake2_update_blocks #Spec.Blake2S #Core.M32 blake2s_update_multi blake2s_update_last [@CInline] private
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s_update:Impl.blake2_update_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s_update
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 85, "end_line": 32, "start_col": 2, "start_line": 32 }
Prims.Tot
val blake2s_finish:Impl.blake2_finish_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s_finish : Impl.blake2_finish_st Spec.Blake2S Core.M32 = Impl.blake2_finish #Spec.Blake2S #Core.M32
val blake2s_finish:Impl.blake2_finish_st Spec.Blake2S Core.M32 let blake2s_finish:Impl.blake2_finish_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2_finish #Spec.Blake2S #Core.M32
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_finish", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32 let blake2s_init : Impl.blake2_init_st Spec.Blake2S Core.M32 = Impl.blake2_init #Spec.Blake2S #Core.M32 let blake2s_update_key : Impl.blake2_update_key_st Spec.Blake2S Core.M32 = Impl.blake2_update_key #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_multi : Impl.blake2_update_multi_st Spec.Blake2S Core.M32 = Impl.blake2_update_multi #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_last : Impl.blake2_update_last_st Spec.Blake2S Core.M32 = Impl.blake2_update_last #Spec.Blake2S #Core.M32 blake2s_update_block private let blake2s_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2S Core.M32 = Impl.blake2_update_blocks #Spec.Blake2S #Core.M32 blake2s_update_multi blake2s_update_last [@CInline] private let blake2s_update : Impl.blake2_update_st Spec.Blake2S Core.M32 = Impl.blake2_update #Spec.Blake2S #Core.M32 blake2s_update_key blake2s_update_blocks
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s_finish:Impl.blake2_finish_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s_finish
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_finish_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 44, "end_line": 35, "start_col": 2, "start_line": 35 }
Prims.Tot
val blake2s_update_blocks:Impl.blake2_update_blocks_st Spec.Blake2S Core.M32
[ { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Core", "short_module": "Core" }, { "abbrev": true, "full_module": "Hacl.Impl.Blake2.Generic", "short_module": "Impl" }, { "abbrev": true, "full_module": "Spec.Blake2", "short_module": "Spec" }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "Hacl", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let blake2s_update_blocks : Impl.blake2_update_blocks_st Spec.Blake2S Core.M32 = Impl.blake2_update_blocks #Spec.Blake2S #Core.M32 blake2s_update_multi blake2s_update_last
val blake2s_update_blocks:Impl.blake2_update_blocks_st Spec.Blake2S Core.M32 let blake2s_update_blocks:Impl.blake2_update_blocks_st Spec.Blake2S Core.M32 =
false
null
false
Impl.blake2_update_blocks #Spec.Blake2S #Core.M32 blake2s_update_multi blake2s_update_last
{ "checked_file": "Hacl.Blake2s_32.fst.checked", "dependencies": [ "Spec.Blake2.fst.checked", "prims.fst.checked", "Hacl.Impl.Blake2.Generic.fst.checked", "Hacl.Impl.Blake2.Core.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Blake2s_32.fst" }
[ "total" ]
[ "Hacl.Impl.Blake2.Generic.blake2_update_blocks", "Spec.Blake2.Blake2S", "Hacl.Impl.Blake2.Core.M32", "Hacl.Blake2s_32.blake2s_update_multi", "Hacl.Blake2s_32.blake2s_update_last" ]
[]
module Hacl.Blake2s_32 module Spec = Spec.Blake2 module Impl = Hacl.Impl.Blake2.Generic module Core = Hacl.Impl.Blake2.Core (* Some specialized components of blake2 *) [@CInline] private let blake2s_update_block : Impl.blake2_update_block_st Spec.Blake2S Core.M32 = Impl.blake2_update_block #Spec.Blake2S #Core.M32 let blake2s_init : Impl.blake2_init_st Spec.Blake2S Core.M32 = Impl.blake2_init #Spec.Blake2S #Core.M32 let blake2s_update_key : Impl.blake2_update_key_st Spec.Blake2S Core.M32 = Impl.blake2_update_key #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_multi : Impl.blake2_update_multi_st Spec.Blake2S Core.M32 = Impl.blake2_update_multi #Spec.Blake2S #Core.M32 blake2s_update_block let blake2s_update_last : Impl.blake2_update_last_st Spec.Blake2S Core.M32 = Impl.blake2_update_last #Spec.Blake2S #Core.M32 blake2s_update_block private
false
false
Hacl.Blake2s_32.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val blake2s_update_blocks:Impl.blake2_update_blocks_st Spec.Blake2S Core.M32
[]
Hacl.Blake2s_32.blake2s_update_blocks
{ "file_name": "code/blake2/Hacl.Blake2s_32.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Blake2.Generic.blake2_update_blocks_st Spec.Blake2.Blake2S Hacl.Impl.Blake2.Core.M32
{ "end_col": 92, "end_line": 27, "start_col": 2, "start_line": 27 }
FStar.HyperStack.ST.Stack
val point_add_: out:point -> p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ disjoint tmp out /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_add (F51.point_eval h0 p) (F51.point_eval h0 q))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "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.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_add_ out p q tmp = point_add_step_1 p q tmp; point_add_step_2 p q tmp; let tmp_g = sub tmp 0ul 5ul in let tmp_h = sub tmp 5ul 5ul in let tmp_e = sub tmp 20ul 5ul in let tmp_f = sub tmp 25ul 5ul in let x3 = getx out in let y3 = gety out in let z3 = getz out in let t3 = gett out in fmul x3 tmp_e tmp_f; fmul y3 tmp_g tmp_h; fmul t3 tmp_e tmp_h; fmul z3 tmp_f tmp_g
val point_add_: out:point -> p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ disjoint tmp out /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) let point_add_ out p q tmp =
true
null
false
point_add_step_1 p q tmp; point_add_step_2 p q tmp; let tmp_g = sub tmp 0ul 5ul in let tmp_h = sub tmp 5ul 5ul in let tmp_e = sub tmp 20ul 5ul in let tmp_f = sub tmp 25ul 5ul in let x3 = getx out in let y3 = gety out in let z3 = getz out in let t3 = gett out in fmul x3 tmp_e tmp_f; fmul y3 tmp_g tmp_h; fmul t3 tmp_e tmp_h; fmul z3 tmp_f tmp_g
{ "checked_file": "Hacl.Impl.Ed25519.PointAdd.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointAdd.fst" }
[]
[ "Hacl.Bignum25519.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Bignum25519.fmul", "Prims.unit", "Hacl.Bignum25519.felem", "Hacl.Bignum25519.gett", "Hacl.Bignum25519.getz", "Hacl.Bignum25519.gety", "Hacl.Bignum25519.getx", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "Hacl.Impl.Ed25519.PointAdd.point_add_step_2", "Hacl.Impl.Ed25519.PointAdd.point_add_step_1" ]
[]
module Hacl.Impl.Ed25519.PointAdd module ST = FStar.HyperStack.ST open FStar.HyperStack.All open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val point_add_step_1: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1 = F51.fevalh h0 (gsub p 0ul 5ul) in let y1 = F51.fevalh h0 (gsub p 5ul 5ul) in let x2 = F51.fevalh h0 (gsub q 0ul 5ul) in let y2 = F51.fevalh h0 (gsub q 5ul 5ul) in let a = (y1 `SC.fsub` x1) `SC.fmul` (y2 `SC.fsub` x2) in let b = (y1 `SC.fadd` x1) `SC.fmul` (y2 `SC.fadd` x2) in F51.mul_inv_t h1 (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h1 (gsub tmp 15ul 5ul) /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == a /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == b)) let point_add_step_1 p q tmp = let tmp1 = sub tmp 0ul 5ul in let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in let tmp4 = sub tmp 15ul 5ul in let x1 = getx p in let y1 = gety p in let x2 = getx q in let y2 = gety q in fdifference tmp1 y1 x1; // tmp1 = y1 - x1 fdifference tmp2 y2 x2; // tmp2 = y2 - x2 fmul tmp3 tmp1 tmp2; // tmp3 = a fsum tmp1 y1 x1; // tmp1 = y1 + x1 fsum tmp2 y2 x2; // tmp2 = y2 + x2 fmul tmp4 tmp1 tmp2 // tmp4 = b inline_for_extraction noextract val point_add_step_2: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q /\ F51.mul_inv_t h (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h (gsub tmp 15ul 5ul)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let z1 = F51.fevalh h0 (gsub p 10ul 5ul) in let t1 = F51.fevalh h0 (gsub p 15ul 5ul) in let z2 = F51.fevalh h0 (gsub q 10ul 5ul) in let t2 = F51.fevalh h0 (gsub q 15ul 5ul) in let a = F51.fevalh h0 (gsub tmp 10ul 5ul) in let b = F51.fevalh h0 (gsub tmp 15ul 5ul) in let c = (2 `SC.fmul` Spec.Ed25519.d `SC.fmul` t1) `SC.fmul` t2 in let d = (2 `SC.fmul` z1) `SC.fmul` z2 in let e = b `SC.fsub` a in let f = d `SC.fsub` c in let g = d `SC.fadd` c in let h = b `SC.fadd` a in F51.felem_fits h1 (gsub tmp 20ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 25ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 20ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 25ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == h)) let point_add_step_2 p q tmp = let tmp1 = sub tmp 0ul 5ul in // g let tmp2 = sub tmp 5ul 5ul in // h let tmp3 = sub tmp 10ul 5ul in // a let tmp4 = sub tmp 15ul 5ul in // b let tmp5 = sub tmp 20ul 5ul in // e let tmp6 = sub tmp 25ul 5ul in // f let z1 = getz p in let t1 = gett p in let z2 = getz q in let t2 = gett q in times_2d tmp1 t1; // tmp1 = 2 * d * t1 fmul tmp1 tmp1 t2; // tmp1 = tmp1 * t2 = c times_2 tmp2 z1; // tmp2 = 2 * z1 fmul tmp2 tmp2 z2; // tmp2 = tmp2 * z2 = d fdifference tmp5 tmp4 tmp3; // tmp5 = e = b - a = tmp4 - tmp3 fdifference tmp6 tmp2 tmp1; // tmp6 = f = d - c = tmp2 - tmp1 fsum tmp1 tmp2 tmp1; // tmp1 = g = d + c = tmp2 + tmp1 fsum tmp2 tmp4 tmp3 // tmp2 = h = b + a = tmp4 - tmp3 inline_for_extraction noextract val point_add_: out:point -> p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ disjoint tmp out /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_add (F51.point_eval h0 p) (F51.point_eval h0 q))
false
false
Hacl.Impl.Ed25519.PointAdd.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 point_add_: out:point -> p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ disjoint tmp out /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_add (F51.point_eval h0 p) (F51.point_eval h0 q))
[]
Hacl.Impl.Ed25519.PointAdd.point_add_
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointAdd.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Bignum25519.point -> p: Hacl.Bignum25519.point -> q: Hacl.Bignum25519.point -> tmp: Lib.Buffer.lbuffer Lib.IntTypes.uint64 30ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 21, "end_line": 129, "start_col": 2, "start_line": 116 }
FStar.HyperStack.ST.Stack
val point_add: out:point -> p:point -> q:point -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_add (F51.point_eval h0 p) (F51.point_eval h0 q))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "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.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_add out p q = push_frame(); let tmp = create 30ul (u64 0) in point_add_ out p q tmp; pop_frame()
val point_add: out:point -> p:point -> q:point -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) let point_add out p q =
true
null
false
push_frame (); let tmp = create 30ul (u64 0) in point_add_ out p q tmp; pop_frame ()
{ "checked_file": "Hacl.Impl.Ed25519.PointAdd.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointAdd.fst" }
[]
[ "Hacl.Bignum25519.point", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.Ed25519.PointAdd.point_add_", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.create", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.Ed25519.PointAdd module ST = FStar.HyperStack.ST open FStar.HyperStack.All open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val point_add_step_1: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1 = F51.fevalh h0 (gsub p 0ul 5ul) in let y1 = F51.fevalh h0 (gsub p 5ul 5ul) in let x2 = F51.fevalh h0 (gsub q 0ul 5ul) in let y2 = F51.fevalh h0 (gsub q 5ul 5ul) in let a = (y1 `SC.fsub` x1) `SC.fmul` (y2 `SC.fsub` x2) in let b = (y1 `SC.fadd` x1) `SC.fmul` (y2 `SC.fadd` x2) in F51.mul_inv_t h1 (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h1 (gsub tmp 15ul 5ul) /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == a /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == b)) let point_add_step_1 p q tmp = let tmp1 = sub tmp 0ul 5ul in let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in let tmp4 = sub tmp 15ul 5ul in let x1 = getx p in let y1 = gety p in let x2 = getx q in let y2 = gety q in fdifference tmp1 y1 x1; // tmp1 = y1 - x1 fdifference tmp2 y2 x2; // tmp2 = y2 - x2 fmul tmp3 tmp1 tmp2; // tmp3 = a fsum tmp1 y1 x1; // tmp1 = y1 + x1 fsum tmp2 y2 x2; // tmp2 = y2 + x2 fmul tmp4 tmp1 tmp2 // tmp4 = b inline_for_extraction noextract val point_add_step_2: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q /\ F51.mul_inv_t h (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h (gsub tmp 15ul 5ul)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let z1 = F51.fevalh h0 (gsub p 10ul 5ul) in let t1 = F51.fevalh h0 (gsub p 15ul 5ul) in let z2 = F51.fevalh h0 (gsub q 10ul 5ul) in let t2 = F51.fevalh h0 (gsub q 15ul 5ul) in let a = F51.fevalh h0 (gsub tmp 10ul 5ul) in let b = F51.fevalh h0 (gsub tmp 15ul 5ul) in let c = (2 `SC.fmul` Spec.Ed25519.d `SC.fmul` t1) `SC.fmul` t2 in let d = (2 `SC.fmul` z1) `SC.fmul` z2 in let e = b `SC.fsub` a in let f = d `SC.fsub` c in let g = d `SC.fadd` c in let h = b `SC.fadd` a in F51.felem_fits h1 (gsub tmp 20ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 25ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 20ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 25ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == h)) let point_add_step_2 p q tmp = let tmp1 = sub tmp 0ul 5ul in // g let tmp2 = sub tmp 5ul 5ul in // h let tmp3 = sub tmp 10ul 5ul in // a let tmp4 = sub tmp 15ul 5ul in // b let tmp5 = sub tmp 20ul 5ul in // e let tmp6 = sub tmp 25ul 5ul in // f let z1 = getz p in let t1 = gett p in let z2 = getz q in let t2 = gett q in times_2d tmp1 t1; // tmp1 = 2 * d * t1 fmul tmp1 tmp1 t2; // tmp1 = tmp1 * t2 = c times_2 tmp2 z1; // tmp2 = 2 * z1 fmul tmp2 tmp2 z2; // tmp2 = tmp2 * z2 = d fdifference tmp5 tmp4 tmp3; // tmp5 = e = b - a = tmp4 - tmp3 fdifference tmp6 tmp2 tmp1; // tmp6 = f = d - c = tmp2 - tmp1 fsum tmp1 tmp2 tmp1; // tmp1 = g = d + c = tmp2 + tmp1 fsum tmp2 tmp4 tmp3 // tmp2 = h = b + a = tmp4 - tmp3 inline_for_extraction noextract val point_add_: out:point -> p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ disjoint tmp out /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc out |+| loc tmp) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) let point_add_ out p q tmp = point_add_step_1 p q tmp; point_add_step_2 p q tmp; let tmp_g = sub tmp 0ul 5ul in let tmp_h = sub tmp 5ul 5ul in let tmp_e = sub tmp 20ul 5ul in let tmp_f = sub tmp 25ul 5ul in let x3 = getx out in let y3 = gety out in let z3 = getz out in let t3 = gett out in fmul x3 tmp_e tmp_f; fmul y3 tmp_g tmp_h; fmul t3 tmp_e tmp_h; fmul z3 tmp_f tmp_g val point_add: out:point -> p:point -> q:point -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_add (F51.point_eval h0 p) (F51.point_eval h0 q))
false
false
Hacl.Impl.Ed25519.PointAdd.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 point_add: out:point -> p:point -> q:point -> Stack unit (requires fun h -> live h out /\ live h p /\ live h q /\ eq_or_disjoint p out /\ eq_or_disjoint q out /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ F51.point_inv_t h1 out /\ F51.point_eval h1 out == Spec.Ed25519.point_add (F51.point_eval h0 p) (F51.point_eval h0 q))
[]
Hacl.Impl.Ed25519.PointAdd.point_add
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointAdd.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Bignum25519.point -> p: Hacl.Bignum25519.point -> q: Hacl.Bignum25519.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 13, "end_line": 145, "start_col": 2, "start_line": 142 }
FStar.HyperStack.ST.Stack
val point_add_step_1: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1 = F51.fevalh h0 (gsub p 0ul 5ul) in let y1 = F51.fevalh h0 (gsub p 5ul 5ul) in let x2 = F51.fevalh h0 (gsub q 0ul 5ul) in let y2 = F51.fevalh h0 (gsub q 5ul 5ul) in let a = (y1 `SC.fsub` x1) `SC.fmul` (y2 `SC.fsub` x2) in let b = (y1 `SC.fadd` x1) `SC.fmul` (y2 `SC.fadd` x2) in F51.mul_inv_t h1 (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h1 (gsub tmp 15ul 5ul) /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == a /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == b))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "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.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_add_step_1 p q tmp = let tmp1 = sub tmp 0ul 5ul in let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in let tmp4 = sub tmp 15ul 5ul in let x1 = getx p in let y1 = gety p in let x2 = getx q in let y2 = gety q in fdifference tmp1 y1 x1; // tmp1 = y1 - x1 fdifference tmp2 y2 x2; // tmp2 = y2 - x2 fmul tmp3 tmp1 tmp2; // tmp3 = a fsum tmp1 y1 x1; // tmp1 = y1 + x1 fsum tmp2 y2 x2; // tmp2 = y2 + x2 fmul tmp4 tmp1 tmp2
val point_add_step_1: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1 = F51.fevalh h0 (gsub p 0ul 5ul) in let y1 = F51.fevalh h0 (gsub p 5ul 5ul) in let x2 = F51.fevalh h0 (gsub q 0ul 5ul) in let y2 = F51.fevalh h0 (gsub q 5ul 5ul) in let a = (y1 `SC.fsub` x1) `SC.fmul` (y2 `SC.fsub` x2) in let b = (y1 `SC.fadd` x1) `SC.fmul` (y2 `SC.fadd` x2) in F51.mul_inv_t h1 (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h1 (gsub tmp 15ul 5ul) /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == a /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == b)) let point_add_step_1 p q tmp =
true
null
false
let tmp1 = sub tmp 0ul 5ul in let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in let tmp4 = sub tmp 15ul 5ul in let x1 = getx p in let y1 = gety p in let x2 = getx q in let y2 = gety q in fdifference tmp1 y1 x1; fdifference tmp2 y2 x2; fmul tmp3 tmp1 tmp2; fsum tmp1 y1 x1; fsum tmp2 y2 x2; fmul tmp4 tmp1 tmp2
{ "checked_file": "Hacl.Impl.Ed25519.PointAdd.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointAdd.fst" }
[]
[ "Hacl.Bignum25519.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Bignum25519.fmul", "Prims.unit", "Hacl.Bignum25519.fsum", "Hacl.Bignum25519.fdifference", "Hacl.Bignum25519.felem", "Hacl.Bignum25519.gety", "Hacl.Bignum25519.getx", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
module Hacl.Impl.Ed25519.PointAdd module ST = FStar.HyperStack.ST open FStar.HyperStack.All open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val point_add_step_1: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1 = F51.fevalh h0 (gsub p 0ul 5ul) in let y1 = F51.fevalh h0 (gsub p 5ul 5ul) in let x2 = F51.fevalh h0 (gsub q 0ul 5ul) in let y2 = F51.fevalh h0 (gsub q 5ul 5ul) in let a = (y1 `SC.fsub` x1) `SC.fmul` (y2 `SC.fsub` x2) in let b = (y1 `SC.fadd` x1) `SC.fmul` (y2 `SC.fadd` x2) in F51.mul_inv_t h1 (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h1 (gsub tmp 15ul 5ul) /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == a /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == b))
false
false
Hacl.Impl.Ed25519.PointAdd.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 point_add_step_1: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1 = F51.fevalh h0 (gsub p 0ul 5ul) in let y1 = F51.fevalh h0 (gsub p 5ul 5ul) in let x2 = F51.fevalh h0 (gsub q 0ul 5ul) in let y2 = F51.fevalh h0 (gsub q 5ul 5ul) in let a = (y1 `SC.fsub` x1) `SC.fmul` (y2 `SC.fsub` x2) in let b = (y1 `SC.fadd` x1) `SC.fmul` (y2 `SC.fadd` x2) in F51.mul_inv_t h1 (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h1 (gsub tmp 15ul 5ul) /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == a /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == b))
[]
Hacl.Impl.Ed25519.PointAdd.point_add_step_1
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointAdd.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Bignum25519.point -> q: Hacl.Bignum25519.point -> tmp: Lib.Buffer.lbuffer Lib.IntTypes.uint64 30ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 21, "end_line": 48, "start_col": 30, "start_line": 34 }
FStar.HyperStack.ST.Stack
val point_add_step_2: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q /\ F51.mul_inv_t h (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h (gsub tmp 15ul 5ul)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let z1 = F51.fevalh h0 (gsub p 10ul 5ul) in let t1 = F51.fevalh h0 (gsub p 15ul 5ul) in let z2 = F51.fevalh h0 (gsub q 10ul 5ul) in let t2 = F51.fevalh h0 (gsub q 15ul 5ul) in let a = F51.fevalh h0 (gsub tmp 10ul 5ul) in let b = F51.fevalh h0 (gsub tmp 15ul 5ul) in let c = (2 `SC.fmul` Spec.Ed25519.d `SC.fmul` t1) `SC.fmul` t2 in let d = (2 `SC.fmul` z1) `SC.fmul` z2 in let e = b `SC.fsub` a in let f = d `SC.fsub` c in let g = d `SC.fadd` c in let h = b `SC.fadd` a in F51.felem_fits h1 (gsub tmp 20ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 25ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 20ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 25ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == h))
[ { "abbrev": true, "full_module": "Spec.Curve25519", "short_module": "SC" }, { "abbrev": true, "full_module": "Hacl.Impl.Ed25519.Field51", "short_module": "F51" }, { "abbrev": false, "full_module": "Hacl.Bignum25519", "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.HyperStack.All", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.Ed25519", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_add_step_2 p q tmp = let tmp1 = sub tmp 0ul 5ul in // g let tmp2 = sub tmp 5ul 5ul in // h let tmp3 = sub tmp 10ul 5ul in // a let tmp4 = sub tmp 15ul 5ul in // b let tmp5 = sub tmp 20ul 5ul in // e let tmp6 = sub tmp 25ul 5ul in // f let z1 = getz p in let t1 = gett p in let z2 = getz q in let t2 = gett q in times_2d tmp1 t1; // tmp1 = 2 * d * t1 fmul tmp1 tmp1 t2; // tmp1 = tmp1 * t2 = c times_2 tmp2 z1; // tmp2 = 2 * z1 fmul tmp2 tmp2 z2; // tmp2 = tmp2 * z2 = d fdifference tmp5 tmp4 tmp3; // tmp5 = e = b - a = tmp4 - tmp3 fdifference tmp6 tmp2 tmp1; // tmp6 = f = d - c = tmp2 - tmp1 fsum tmp1 tmp2 tmp1; // tmp1 = g = d + c = tmp2 + tmp1 fsum tmp2 tmp4 tmp3
val point_add_step_2: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q /\ F51.mul_inv_t h (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h (gsub tmp 15ul 5ul)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let z1 = F51.fevalh h0 (gsub p 10ul 5ul) in let t1 = F51.fevalh h0 (gsub p 15ul 5ul) in let z2 = F51.fevalh h0 (gsub q 10ul 5ul) in let t2 = F51.fevalh h0 (gsub q 15ul 5ul) in let a = F51.fevalh h0 (gsub tmp 10ul 5ul) in let b = F51.fevalh h0 (gsub tmp 15ul 5ul) in let c = (2 `SC.fmul` Spec.Ed25519.d `SC.fmul` t1) `SC.fmul` t2 in let d = (2 `SC.fmul` z1) `SC.fmul` z2 in let e = b `SC.fsub` a in let f = d `SC.fsub` c in let g = d `SC.fadd` c in let h = b `SC.fadd` a in F51.felem_fits h1 (gsub tmp 20ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 25ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 20ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 25ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == h)) let point_add_step_2 p q tmp =
true
null
false
let tmp1 = sub tmp 0ul 5ul in let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in let tmp4 = sub tmp 15ul 5ul in let tmp5 = sub tmp 20ul 5ul in let tmp6 = sub tmp 25ul 5ul in let z1 = getz p in let t1 = gett p in let z2 = getz q in let t2 = gett q in times_2d tmp1 t1; fmul tmp1 tmp1 t2; times_2 tmp2 z1; fmul tmp2 tmp2 z2; fdifference tmp5 tmp4 tmp3; fdifference tmp6 tmp2 tmp1; fsum tmp1 tmp2 tmp1; fsum tmp2 tmp4 tmp3
{ "checked_file": "Hacl.Impl.Ed25519.PointAdd.fst.checked", "dependencies": [ "Spec.Ed25519.fst.checked", "Spec.Curve25519.fst.checked", "prims.fst.checked", "Lib.IntTypes.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Impl.Ed25519.Field51.fst.checked", "Hacl.Bignum25519.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked" ], "interface_file": false, "source_file": "Hacl.Impl.Ed25519.PointAdd.fst" }
[]
[ "Hacl.Bignum25519.point", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Hacl.Bignum25519.fsum", "Prims.unit", "Hacl.Bignum25519.fdifference", "Hacl.Bignum25519.fmul", "Hacl.Bignum25519.times_2", "Hacl.Bignum25519.times_2d", "Hacl.Bignum25519.felem", "Hacl.Bignum25519.gett", "Hacl.Bignum25519.getz", "Lib.Buffer.lbuffer_t", "Lib.Buffer.MUT", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub" ]
[]
module Hacl.Impl.Ed25519.PointAdd module ST = FStar.HyperStack.ST open FStar.HyperStack.All open Lib.IntTypes open Lib.Buffer open Hacl.Bignum25519 module F51 = Hacl.Impl.Ed25519.Field51 module SC = Spec.Curve25519 #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract val point_add_step_1: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let x1 = F51.fevalh h0 (gsub p 0ul 5ul) in let y1 = F51.fevalh h0 (gsub p 5ul 5ul) in let x2 = F51.fevalh h0 (gsub q 0ul 5ul) in let y2 = F51.fevalh h0 (gsub q 5ul 5ul) in let a = (y1 `SC.fsub` x1) `SC.fmul` (y2 `SC.fsub` x2) in let b = (y1 `SC.fadd` x1) `SC.fmul` (y2 `SC.fadd` x2) in F51.mul_inv_t h1 (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h1 (gsub tmp 15ul 5ul) /\ F51.fevalh h1 (gsub tmp 10ul 5ul) == a /\ F51.fevalh h1 (gsub tmp 15ul 5ul) == b)) let point_add_step_1 p q tmp = let tmp1 = sub tmp 0ul 5ul in let tmp2 = sub tmp 5ul 5ul in let tmp3 = sub tmp 10ul 5ul in let tmp4 = sub tmp 15ul 5ul in let x1 = getx p in let y1 = gety p in let x2 = getx q in let y2 = gety q in fdifference tmp1 y1 x1; // tmp1 = y1 - x1 fdifference tmp2 y2 x2; // tmp2 = y2 - x2 fmul tmp3 tmp1 tmp2; // tmp3 = a fsum tmp1 y1 x1; // tmp1 = y1 + x1 fsum tmp2 y2 x2; // tmp2 = y2 + x2 fmul tmp4 tmp1 tmp2 // tmp4 = b inline_for_extraction noextract val point_add_step_2: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q /\ F51.mul_inv_t h (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h (gsub tmp 15ul 5ul)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let z1 = F51.fevalh h0 (gsub p 10ul 5ul) in let t1 = F51.fevalh h0 (gsub p 15ul 5ul) in let z2 = F51.fevalh h0 (gsub q 10ul 5ul) in let t2 = F51.fevalh h0 (gsub q 15ul 5ul) in let a = F51.fevalh h0 (gsub tmp 10ul 5ul) in let b = F51.fevalh h0 (gsub tmp 15ul 5ul) in let c = (2 `SC.fmul` Spec.Ed25519.d `SC.fmul` t1) `SC.fmul` t2 in let d = (2 `SC.fmul` z1) `SC.fmul` z2 in let e = b `SC.fsub` a in let f = d `SC.fsub` c in let g = d `SC.fadd` c in let h = b `SC.fadd` a in F51.felem_fits h1 (gsub tmp 20ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 25ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 20ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 25ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == h))
false
false
Hacl.Impl.Ed25519.PointAdd.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 point_add_step_2: p:point -> q:point -> tmp:lbuffer uint64 30ul -> Stack unit (requires fun h -> live h p /\ live h q /\ live h tmp /\ disjoint tmp p /\ disjoint tmp q /\ F51.point_inv_t h p /\ F51.point_inv_t h q /\ F51.mul_inv_t h (gsub tmp 10ul 5ul) /\ F51.mul_inv_t h (gsub tmp 15ul 5ul)) (ensures fun h0 _ h1 -> modifies (loc tmp) h0 h1 /\ (let z1 = F51.fevalh h0 (gsub p 10ul 5ul) in let t1 = F51.fevalh h0 (gsub p 15ul 5ul) in let z2 = F51.fevalh h0 (gsub q 10ul 5ul) in let t2 = F51.fevalh h0 (gsub q 15ul 5ul) in let a = F51.fevalh h0 (gsub tmp 10ul 5ul) in let b = F51.fevalh h0 (gsub tmp 15ul 5ul) in let c = (2 `SC.fmul` Spec.Ed25519.d `SC.fmul` t1) `SC.fmul` t2 in let d = (2 `SC.fmul` z1) `SC.fmul` z2 in let e = b `SC.fsub` a in let f = d `SC.fsub` c in let g = d `SC.fadd` c in let h = b `SC.fadd` a in F51.felem_fits h1 (gsub tmp 20ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 25ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 0ul 5ul) (9, 10, 9, 9, 9) /\ F51.felem_fits h1 (gsub tmp 5ul 5ul) (9, 10, 9, 9, 9) /\ F51.fevalh h1 (gsub tmp 20ul 5ul) == e /\ F51.fevalh h1 (gsub tmp 25ul 5ul) == f /\ F51.fevalh h1 (gsub tmp 0ul 5ul) == g /\ F51.fevalh h1 (gsub tmp 5ul 5ul) == h))
[]
Hacl.Impl.Ed25519.PointAdd.point_add_step_2
{ "file_name": "code/ed25519/Hacl.Impl.Ed25519.PointAdd.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
p: Hacl.Bignum25519.point -> q: Hacl.Bignum25519.point -> tmp: Lib.Buffer.lbuffer Lib.IntTypes.uint64 30ul -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 21, "end_line": 101, "start_col": 30, "start_line": 81 }
FStar.Pervasives.Lemma
val splitAt_length_total (#a: Type) (l: list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs
val splitAt_length_total (#a: Type) (l: list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) let rec splitAt_length_total (#a: Type) (l: list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) =
false
null
true
match l with | [] -> () | x :: xs -> splitAt_length_total xs
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma", "" ]
[ "Prims.list", "FStar.List.Pure.Properties.splitAt_length_total", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "FStar.List.Tot.Base.length", "FStar.Pervasives.Native.Mktuple2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l)
false
false
FStar.List.Pure.Properties.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 splitAt_length_total (#a: Type) (l: list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l)
[ "recursion" ]
FStar.List.Pure.Properties.splitAt_length_total
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list a -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.splitAt (FStar.List.Tot.Base.length l) l == FStar.Pervasives.Native.Mktuple2 l []) (decreases l)
{ "end_col": 38, "end_line": 69, "start_col": 2, "start_line": 67 }
FStar.Pervasives.Lemma
val lemma_split3_append (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in l == append a (b :: c)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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_split3_append (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in l == append a (b :: c))) = lemma_splitAt_append n l
val lemma_split3_append (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in l == append a (b :: c))) let lemma_split3_append (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in l == append a (b :: c))) =
false
null
true
lemma_splitAt_append n l
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "FStar.List.Pure.Properties.lemma_splitAt_append", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.append", "Prims.Cons", "FStar.Pervasives.Native.tuple3", "FStar.List.Tot.Base.split3", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1) (** Doing an [index] on the left-part of a [splitAt] is same as doing it on the original list *) let rec lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) = match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1) (** Doing an [index] on the right-part of a [splitAt] is same as doing it on the original list, but shifted *) let rec lemma_splitAt_reindex_right (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) = match i with | 0 -> () | _ -> lemma_splitAt_reindex_right (i - 1) (tl l) j (** Properties of split3 *) (** The 3 pieces returned via [split3] can be joined together via an [append] and a [cons] *) let lemma_split3_append (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in
false
false
FStar.List.Pure.Properties.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 lemma_split3_append (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in l == append a (b :: c)))
[]
FStar.List.Pure.Properties.lemma_split3_append
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> n: Prims.nat{n < FStar.List.Tot.Base.length l} -> FStar.Pervasives.Lemma (ensures (let _ = FStar.List.Tot.Base.split3 l n in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ a b c = _ in l == a @ b :: c) <: Type0))
{ "end_col": 26, "end_line": 169, "start_col": 2, "start_line": 169 }
FStar.Pervasives.Lemma
val lemma_split3_index (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in b == index l n))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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_split3_index (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in b == index l n)) = lemma_splitAt_index_hd n l
val lemma_split3_index (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in b == index l n)) let lemma_split3_index (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in b == index l n)) =
false
null
true
lemma_splitAt_index_hd n l
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "FStar.List.Pure.Properties.lemma_splitAt_index_hd", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.index", "FStar.Pervasives.Native.tuple3", "FStar.List.Tot.Base.split3", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1) (** Doing an [index] on the left-part of a [splitAt] is same as doing it on the original list *) let rec lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) = match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1) (** Doing an [index] on the right-part of a [splitAt] is same as doing it on the original list, but shifted *) let rec lemma_splitAt_reindex_right (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) = match i with | 0 -> () | _ -> lemma_splitAt_reindex_right (i - 1) (tl l) j (** Properties of split3 *) (** The 3 pieces returned via [split3] can be joined together via an [append] and a [cons] *) let lemma_split3_append (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in l == append a (b :: c))) = lemma_splitAt_append n l (** The middle element returned via [split3] is the [n]th [index]ed element *) let lemma_split3_index (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in
false
false
FStar.List.Pure.Properties.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 lemma_split3_index (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in b == index l n))
[]
FStar.List.Pure.Properties.lemma_split3_index
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> n: Prims.nat{n < FStar.List.Tot.Base.length l} -> FStar.Pervasives.Lemma (ensures (let _ = FStar.List.Tot.Base.split3 l n in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ _ b _ = _ in b == FStar.List.Tot.Base.index l n) <: Type0))
{ "end_col": 28, "end_line": 179, "start_col": 2, "start_line": 179 }
FStar.Pervasives.Lemma
val lemma_append_splitAt (#t: Type) (l1 l2: list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2
val lemma_append_splitAt (#t: Type) (l1 l2: list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) let rec lemma_append_splitAt (#t: Type) (l1 l2: list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) =
false
null
true
match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "FStar.List.Pure.Properties.lemma_append_splitAt", "FStar.List.Tot.Base.tl", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "FStar.List.Tot.Base.length", "FStar.List.Tot.Base.append", "FStar.Pervasives.Native.Mktuple2", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma
false
false
FStar.List.Pure.Properties.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 lemma_append_splitAt (#t: Type) (l1 l2: list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2)))
[ "recursion" ]
FStar.List.Pure.Properties.lemma_append_splitAt
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list t -> l2: Prims.list t -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.splitAt (FStar.List.Tot.Base.length l1) (l1 @ l2) == FStar.Pervasives.Native.Mktuple2 l1 l2)
{ "end_col": 40, "end_line": 94, "start_col": 2, "start_line": 92 }
FStar.Pervasives.Lemma
val lemma_splitAt (#t: Type) (l l1 l2: list t) (n: nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2
val lemma_splitAt (#t: Type) (l l1 l2: list t) (n: nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) let lemma_splitAt (#t: Type) (l l1 l2: list t) (n: nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) =
false
null
true
lemma_splitAt_append n l; lemma_append_splitAt l1 l2
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.List.Tot.Base.length", "FStar.List.Pure.Properties.lemma_append_splitAt", "Prims.unit", "FStar.List.Pure.Properties.lemma_splitAt_append", "Prims.l_True", "Prims.squash", "Prims.l_iff", "Prims.eq2", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "FStar.Pervasives.Native.Mktuple2", "Prims.l_and", "FStar.List.Tot.Base.op_At", "Prims.op_Equality", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) :
false
false
FStar.List.Pure.Properties.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 lemma_splitAt (#t: Type) (l l1 l2: list t) (n: nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n)
[]
FStar.List.Pure.Properties.lemma_splitAt
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> l1: Prims.list t -> l2: Prims.list t -> n: Prims.nat{n <= FStar.List.Tot.Base.length l} -> FStar.Pervasives.Lemma (ensures FStar.List.Tot.Base.splitAt n l == FStar.Pervasives.Native.Mktuple2 l1 l2 <==> l == l1 @ l2 /\ FStar.List.Tot.Base.length l1 = n)
{ "end_col": 28, "end_line": 101, "start_col": 2, "start_line": 100 }
FStar.Pervasives.Lemma
val lemma_splitAt_shorten_left (#t: Type) (l1 l2: list t) (i: nat{i <= length l1 /\ i <= length l2}) (j: nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1)
val lemma_splitAt_shorten_left (#t: Type) (l1 l2: list t) (i: nat{i <= length l1 /\ i <= length l2}) (j: nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) let rec lemma_splitAt_shorten_left (#t: Type) (l1 l2: list t) (i: nat{i <= length l1 /\ i <= length l2}) (j: nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) =
false
null
true
match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i - 1) (j - 1)
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.List.Tot.Base.length", "Prims.int", "FStar.List.Pure.Properties.lemma_splitAt_shorten_left", "FStar.List.Tot.Base.tl", "Prims.op_Subtraction", "Prims.unit", "Prims.eq2", "FStar.Pervasives.Native.fst", "FStar.List.Tot.Base.splitAt", "Prims.squash", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2)))
false
false
FStar.List.Pure.Properties.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 lemma_splitAt_shorten_left (#t: Type) (l1 l2: list t) (i: nat{i <= length l1 /\ i <= length l2}) (j: nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2)))
[ "recursion" ]
FStar.List.Pure.Properties.lemma_splitAt_shorten_left
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list t -> l2: Prims.list t -> i: Prims.nat{i <= FStar.List.Tot.Base.length l1 /\ i <= FStar.List.Tot.Base.length l2} -> j: Prims.nat{j <= i} -> FStar.Pervasives.Lemma (requires FStar.Pervasives.Native.fst (FStar.List.Tot.Base.splitAt i l1) == FStar.Pervasives.Native.fst (FStar.List.Tot.Base.splitAt i l2)) (ensures FStar.Pervasives.Native.fst (FStar.List.Tot.Base.splitAt j l1) == FStar.Pervasives.Native.fst (FStar.List.Tot.Base.splitAt j l2))
{ "end_col": 58, "end_line": 128, "start_col": 2, "start_line": 125 }
FStar.Pervasives.Lemma
val lemma_split3_length (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in length a = n /\ length c = length l - n - 1))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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_split3_length (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in length a = n /\ length c = length l - n - 1)) = splitAt_length n l
val lemma_split3_length (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in length a = n /\ length c = length l - n - 1)) let lemma_split3_length (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in length a = n /\ length c = length l - n - 1)) =
false
null
true
splitAt_length n l
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "FStar.List.Pure.Properties.splitAt_length", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.op_Equality", "Prims.int", "Prims.op_Subtraction", "FStar.Pervasives.Native.tuple3", "FStar.List.Tot.Base.split3", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1) (** Doing an [index] on the left-part of a [splitAt] is same as doing it on the original list *) let rec lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) = match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1) (** Doing an [index] on the right-part of a [splitAt] is same as doing it on the original list, but shifted *) let rec lemma_splitAt_reindex_right (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) = match i with | 0 -> () | _ -> lemma_splitAt_reindex_right (i - 1) (tl l) j (** Properties of split3 *) (** The 3 pieces returned via [split3] can be joined together via an [append] and a [cons] *) let lemma_split3_append (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in l == append a (b :: c))) = lemma_splitAt_append n l (** The middle element returned via [split3] is the [n]th [index]ed element *) let lemma_split3_index (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in b == index l n)) = lemma_splitAt_index_hd n l (** The lengths of the left and right parts of a [split3] are as expected. *) let lemma_split3_length (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in
false
false
FStar.List.Pure.Properties.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 lemma_split3_length (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires True) (ensures (let a, b, c = split3 l n in length a = n /\ length c = length l - n - 1))
[]
FStar.List.Pure.Properties.lemma_split3_length
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> n: Prims.nat{n < FStar.List.Tot.Base.length l} -> FStar.Pervasives.Lemma (ensures (let _ = FStar.List.Tot.Base.split3 l n in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ a _ c = _ in FStar.List.Tot.Base.length a = n /\ FStar.List.Tot.Base.length c = FStar.List.Tot.Base.length l - n - 1) <: Type0))
{ "end_col": 20, "end_line": 189, "start_col": 2, "start_line": 189 }
FStar.Pervasives.Lemma
val splitAt_length (#a: Type) (n: nat) (l: list a) : Lemma (requires True) (ensures (let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n)) (decreases n)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs
val splitAt_length (#a: Type) (n: nat) (l: list a) : Lemma (requires True) (ensures (let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n)) (decreases n) let rec splitAt_length (#a: Type) (n: nat) (l: list a) : Lemma (requires True) (ensures (let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n)) (decreases n) =
false
null
true
if n = 0 then () else match l with | [] -> () | _ :: xs -> splitAt_length (n - 1) xs
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma", "" ]
[ "Prims.nat", "Prims.list", "Prims.op_Equality", "Prims.int", "Prims.bool", "FStar.List.Pure.Properties.splitAt_length", "Prims.op_Subtraction", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.l_and", "Prims.eq2", "Prims.b2t", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n)
false
false
FStar.List.Pure.Properties.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 splitAt_length (#a: Type) (n: nat) (l: list a) : Lemma (requires True) (ensures (let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n)) (decreases n)
[ "recursion" ]
FStar.List.Pure.Properties.splitAt_length
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures (let _ = FStar.List.Tot.Base.splitAt n l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l_1 l_2 = _ in (match FStar.List.Tot.Base.length l < n with | true -> FStar.List.Tot.Base.length l_1 == FStar.List.Tot.Base.length l /\ FStar.List.Tot.Base.length l_2 == 0 | _ -> FStar.List.Tot.Base.length l_1 == n /\ FStar.List.Tot.Base.length l_2 = FStar.List.Tot.Base.length l - n) <: Type0) <: Type0)) (decreases n)
{ "end_col": 38, "end_line": 42, "start_col": 2, "start_line": 38 }
FStar.Pervasives.Lemma
val lemma_unsnoc_split3 (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (requires (i <> length l - 1)) (ensures (let xs, x = unsnoc l in i < length xs /\ (let a0, b0, c0 = split3 l i in let a1, b1, c1 = split3 xs i in a0 == a1 /\ b0 == b1)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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_unsnoc_split3 (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (requires (i <> length l - 1)) (ensures ( let xs, x = unsnoc l in i < length xs /\ ( let a0, b0, c0 = split3 l i in let a1, b1, c1 = split3 xs i in a0 == a1 /\ b0 == b1))) = let xs, x = unsnoc l in lemma_unsnoc_length l; let a0, b0, c0 = split3 l i in let a1, b1, c1 = split3 xs i in splitAt_length_total xs; // assert (fst (splitAt (length xs) xs) == xs); // assert (fst (splitAt (length xs) xs) == fst (splitAt (length xs) l)); // assert (i+1 <= length xs); lemma_splitAt_shorten_left xs l (length xs) (i+1); // assert (fst (splitAt (i+1) xs) == fst (splitAt (i+1) l)); lemma_split3_on_same_leftprefix l xs i
val lemma_unsnoc_split3 (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (requires (i <> length l - 1)) (ensures (let xs, x = unsnoc l in i < length xs /\ (let a0, b0, c0 = split3 l i in let a1, b1, c1 = split3 xs i in a0 == a1 /\ b0 == b1))) let lemma_unsnoc_split3 (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (requires (i <> length l - 1)) (ensures (let xs, x = unsnoc l in i < length xs /\ (let a0, b0, c0 = split3 l i in let a1, b1, c1 = split3 xs i in a0 == a1 /\ b0 == b1))) =
false
null
true
let xs, x = unsnoc l in lemma_unsnoc_length l; let a0, b0, c0 = split3 l i in let a1, b1, c1 = split3 xs i in splitAt_length_total xs; lemma_splitAt_shorten_left xs l (length xs) (i + 1); lemma_split3_on_same_leftprefix l xs i
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "FStar.List.Pure.Properties.lemma_split3_on_same_leftprefix", "Prims.unit", "FStar.List.Pure.Properties.lemma_splitAt_shorten_left", "Prims.op_Addition", "FStar.List.Pure.Properties.splitAt_length_total", "FStar.Pervasives.Native.tuple3", "FStar.List.Tot.Base.split3", "FStar.List.Tot.Properties.lemma_unsnoc_length", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.unsnoc", "Prims.op_disEquality", "Prims.int", "Prims.op_Subtraction", "Prims.squash", "Prims.l_and", "Prims.eq2", "Prims.logical", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1) (** Doing an [index] on the left-part of a [splitAt] is same as doing it on the original list *) let rec lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) = match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1) (** Doing an [index] on the right-part of a [splitAt] is same as doing it on the original list, but shifted *) let rec lemma_splitAt_reindex_right (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) = match i with | 0 -> () | _ -> lemma_splitAt_reindex_right (i - 1) (tl l) j (** Properties of split3 *) (** The 3 pieces returned via [split3] can be joined together via an [append] and a [cons] *) let lemma_split3_append (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in l == append a (b :: c))) = lemma_splitAt_append n l (** The middle element returned via [split3] is the [n]th [index]ed element *) let lemma_split3_index (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in b == index l n)) = lemma_splitAt_index_hd n l (** The lengths of the left and right parts of a [split3] are as expected. *) let lemma_split3_length (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in length a = n /\ length c = length l - n - 1)) = splitAt_length n l (** If we [split3] on lists with the same left prefix, we get the same element and left prefix. *) let lemma_split3_on_same_leftprefix (#t:Type) (l1 l2:list t) (n:nat{n < length l1 /\ n < length l2}) : Lemma (requires (fst (splitAt (n+1) l1) == fst (splitAt (n+1) l2))) (ensures (let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in a1 == a2 /\ b1 == b2)) = let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in lemma_split3_append l1 n; lemma_split3_append l2 n; lemma_split3_length l1 n; lemma_split3_length l2 n; append_l_cons b1 c1 a1; append_l_cons b2 c2 a2; // assert ((a1 @ [b1]) @ c1 == l1); // assert ((a2 @ [b2]) @ c2 == l2); let x1, y1 = splitAt (n+1) l1 in let x2, y2 = splitAt (n+1) l2 in lemma_splitAt_append (n+1) l1; lemma_splitAt_append (n+1) l2; splitAt_length (n+1) l1; splitAt_length (n+1) l2; // assert (x1 @ y1 == (a1 @ [b1]) @ c1); // assert (x2 @ y2 == (a2 @ [b2]) @ c2); append_length_inv_head x1 y1 (append a1 [b1]) c1; append_length_inv_head x2 y2 (append a2 [b2]) c2; // assert (a1 @ [b1] == a2 @ [b2]); append_length_inv_tail a1 [b1] a2 [b2]; // assert (a1 == a2 /\ b1 == b2); () (** If we perform an [unsnoc] on a list, then the left part is the same as an [append]+[cons] on the list after [split3]. *) let rec lemma_split3_unsnoc (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires (n <> length l - 1)) (ensures ( let a, b, c = split3 l n in lemma_split3_length l n; length c > 0 /\ ( let xs, x = unsnoc l in let ys, y = unsnoc c in append a (b :: ys) == xs))) = match n with | 0 -> () | _ -> lemma_split3_unsnoc (tl l) (n-1) (** Doing [unsnoc] and [split3] in either order leads to the same left part, and element. *) let lemma_unsnoc_split3 (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (requires (i <> length l - 1)) (ensures ( let xs, x = unsnoc l in i < length xs /\ ( let a0, b0, c0 = split3 l i in
false
false
FStar.List.Pure.Properties.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 lemma_unsnoc_split3 (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (requires (i <> length l - 1)) (ensures (let xs, x = unsnoc l in i < length xs /\ (let a0, b0, c0 = split3 l i in let a1, b1, c1 = split3 xs i in a0 == a1 /\ b0 == b1)))
[]
FStar.List.Pure.Properties.lemma_unsnoc_split3
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> i: Prims.nat{i < FStar.List.Tot.Base.length l} -> FStar.Pervasives.Lemma (requires i <> FStar.List.Tot.Base.length l - 1) (ensures (let _ = FStar.List.Tot.Base.unsnoc l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ xs _ = _ in i < FStar.List.Tot.Base.length xs /\ (let _ = FStar.List.Tot.Base.split3 l i in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ a0 b0 _ = _ in let _ = FStar.List.Tot.Base.split3 xs i in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ a1 b1 _ = _ in a0 == a1 /\ b0 == b1) <: Prims.logical) <: Prims.logical)) <: Type0))
{ "end_col": 40, "end_line": 265, "start_col": 37, "start_line": 254 }
FStar.Pervasives.Lemma
val lemma_splitAt_append (#a: Type) (n: nat) (l: list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs
val lemma_splitAt_append (#a: Type) (n: nat) (l: list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) let rec lemma_splitAt_append (#a: Type) (n: nat) (l: list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) =
false
null
true
match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n - 1) xs
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.list", "Prims.int", "FStar.List.Pure.Properties.lemma_splitAt_append", "Prims.op_Subtraction", "Prims.unit", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.List.Tot.Base.length", "Prims.squash", "Prims.l_and", "Prims.eq2", "FStar.List.Tot.Base.append", "Prims.op_Equality", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in
false
false
FStar.List.Pure.Properties.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 lemma_splitAt_append (#a: Type) (n: nat) (l: list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n))
[ "recursion" ]
FStar.List.Pure.Properties.lemma_splitAt_append
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> l: Prims.list a -> FStar.Pervasives.Lemma (requires n <= FStar.List.Tot.Base.length l) (ensures (let _ = FStar.List.Tot.Base.splitAt n l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l1 l2 = _ in l1 @ l2 == l /\ FStar.List.Tot.Base.length l1 = n) <: Type0))
{ "end_col": 46, "end_line": 84, "start_col": 2, "start_line": 79 }
FStar.Pervasives.Lemma
val lemma_splitAt_index_hd (#t: Type) (n: nat) (l: list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l)
val lemma_splitAt_index_hd (#t: Type) (n: nat) (l: list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) let rec lemma_splitAt_index_hd (#t: Type) (n: nat) (l: list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) =
false
null
true
let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l)
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.list", "Prims.int", "FStar.List.Pure.Properties.lemma_splitAt_index_hd", "Prims.op_Subtraction", "FStar.List.Tot.Base.tl", "Prims.unit", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.squash", "Prims.l_and", "Prims.op_GreaterThan", "Prims.eq2", "FStar.List.Tot.Base.hd", "FStar.List.Tot.Base.index", "FStar.List.Pure.Properties.splitAt_length", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in
false
false
FStar.List.Pure.Properties.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 lemma_splitAt_index_hd (#t: Type) (n: nat) (l: list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n))
[ "recursion" ]
FStar.List.Pure.Properties.lemma_splitAt_index_hd
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> l: Prims.list t -> FStar.Pervasives.Lemma (requires n < FStar.List.Tot.Base.length l) (ensures (let _ = FStar.List.Tot.Base.splitAt n l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ _ l2 = _ in FStar.List.Pure.Properties.splitAt_length n l; FStar.List.Tot.Base.length l2 > 0 /\ FStar.List.Tot.Base.hd l2 == FStar.List.Tot.Base.index l n) <: Type0))
{ "end_col": 46, "end_line": 115, "start_col": 53, "start_line": 111 }
FStar.Pervasives.Lemma
val lemma_splitAt_reindex_right (#t: Type) (i: nat) (l: list t) (j: nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures (let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 lemma_splitAt_reindex_right (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) = match i with | 0 -> () | _ -> lemma_splitAt_reindex_right (i - 1) (tl l) j
val lemma_splitAt_reindex_right (#t: Type) (i: nat) (l: list t) (j: nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures (let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) let rec lemma_splitAt_reindex_right (#t: Type) (i: nat) (l: list t) (j: nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures (let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) =
false
null
true
match i with | 0 -> () | _ -> lemma_splitAt_reindex_right (i - 1) (tl l) j
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.list", "Prims.int", "FStar.List.Pure.Properties.lemma_splitAt_reindex_right", "Prims.op_Subtraction", "FStar.List.Tot.Base.tl", "Prims.unit", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.List.Tot.Base.length", "Prims.op_LessThan", "Prims.op_Addition", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.index", "FStar.List.Pure.Properties.splitAt_length", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1) (** Doing an [index] on the left-part of a [splitAt] is same as doing it on the original list *) let rec lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) = match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1) (** Doing an [index] on the right-part of a [splitAt] is same as doing it on the original list, but shifted *) let rec lemma_splitAt_reindex_right (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures ( let left, right = splitAt i l in splitAt_length i l;
false
false
FStar.List.Pure.Properties.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 lemma_splitAt_reindex_right (#t: Type) (i: nat) (l: list t) (j: nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures (let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i)))
[ "recursion" ]
FStar.List.Pure.Properties.lemma_splitAt_reindex_right
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
i: Prims.nat -> l: Prims.list t -> j: Prims.nat -> FStar.Pervasives.Lemma (requires i <= FStar.List.Tot.Base.length l /\ j + i < FStar.List.Tot.Base.length l) (ensures (let _ = FStar.List.Tot.Base.splitAt i l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ _ right = _ in FStar.List.Pure.Properties.splitAt_length i l; j < FStar.List.Tot.Base.length right /\ FStar.List.Tot.Base.index right j == FStar.List.Tot.Base.index l (j + i)) <: Type0))
{ "end_col": 53, "end_line": 155, "start_col": 2, "start_line": 153 }
FStar.Pervasives.Lemma
val lemma_splitAt_reindex_left (#t: Type) (i: nat) (l: list t) (j: nat) : Lemma (requires i <= length l /\ j < i) (ensures (let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) = match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1)
val lemma_splitAt_reindex_left (#t: Type) (i: nat) (l: list t) (j: nat) : Lemma (requires i <= length l /\ j < i) (ensures (let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) let rec lemma_splitAt_reindex_left (#t: Type) (i: nat) (l: list t) (j: nat) : Lemma (requires i <= length l /\ j < i) (ensures (let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) =
false
null
true
match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1)
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.nat", "Prims.list", "FStar.Pervasives.Native.Mktuple2", "Prims.int", "FStar.Pervasives.Native.tuple2", "FStar.List.Pure.Properties.lemma_splitAt_reindex_left", "Prims.op_Subtraction", "FStar.List.Tot.Base.tl", "Prims.unit", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "FStar.List.Tot.Base.length", "Prims.op_LessThan", "Prims.squash", "Prims.eq2", "FStar.List.Tot.Base.index", "FStar.List.Pure.Properties.splitAt_length", "FStar.List.Tot.Base.splitAt", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1) (** Doing an [index] on the left-part of a [splitAt] is same as doing it on the original list *) let rec lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l;
false
false
FStar.List.Pure.Properties.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 lemma_splitAt_reindex_left (#t: Type) (i: nat) (l: list t) (j: nat) : Lemma (requires i <= length l /\ j < i) (ensures (let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j))
[ "recursion" ]
FStar.List.Pure.Properties.lemma_splitAt_reindex_left
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
i: Prims.nat -> l: Prims.list t -> j: Prims.nat -> FStar.Pervasives.Lemma (requires i <= FStar.List.Tot.Base.length l /\ j < i) (ensures (let _ = FStar.List.Tot.Base.splitAt i l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ left _ = _ in FStar.List.Pure.Properties.splitAt_length i l; j < FStar.List.Tot.Base.length left /\ FStar.List.Tot.Base.index left j == FStar.List.Tot.Base.index l j) <: Type0))
{ "end_col": 58, "end_line": 141, "start_col": 2, "start_line": 139 }
FStar.Pervasives.Lemma
val splitAt_assoc (#a: Type) (n1 n2: nat) (l: list a) : Lemma (requires True) (ensures (let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1 + n2) l in l1' == l1 @ l2 /\ l2' == l3)) (decreases n1)
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs
val splitAt_assoc (#a: Type) (n1 n2: nat) (l: list a) : Lemma (requires True) (ensures (let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1 + n2) l in l1' == l1 @ l2 /\ l2' == l3)) (decreases n1) let rec splitAt_assoc (#a: Type) (n1 n2: nat) (l: list a) : Lemma (requires True) (ensures (let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1 + n2) l in l1' == l1 @ l2 /\ l2' == l3)) (decreases n1) =
false
null
true
if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1 - 1) n2 xs
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma", "" ]
[ "Prims.nat", "Prims.list", "Prims.op_Equality", "Prims.int", "Prims.bool", "FStar.List.Pure.Properties.splitAt_assoc", "Prims.op_Subtraction", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_and", "Prims.eq2", "FStar.List.Tot.Base.op_At", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "Prims.op_Addition", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1)
false
false
FStar.List.Pure.Properties.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 splitAt_assoc (#a: Type) (n1 n2: nat) (l: list a) : Lemma (requires True) (ensures (let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1 + n2) l in l1' == l1 @ l2 /\ l2' == l3)) (decreases n1)
[ "recursion" ]
FStar.List.Pure.Properties.splitAt_assoc
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n1: Prims.nat -> n2: Prims.nat -> l: Prims.list a -> FStar.Pervasives.Lemma (ensures (let _ = FStar.List.Tot.Base.splitAt n1 l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l1 l2 = _ in let _ = FStar.List.Tot.Base.splitAt n2 l2 in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l2 l3 = _ in let _ = FStar.List.Tot.Base.splitAt (n1 + n2) l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ l1' l2' = _ in l1' == l1 @ l2 /\ l2' == l3) <: Type0) <: Type0) <: Type0)) (decreases n1)
{ "end_col": 43, "end_line": 61, "start_col": 2, "start_line": 57 }
FStar.Pervasives.Lemma
val lemma_split3_r_hd (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (ensures (let a, b, c = split3 l i in lemma_split3_length l i; length c > 0 ==> i + 1 < length l /\ hd c == index l (i + 1)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 lemma_split3_r_hd (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (let a, b, c = split3 l i in lemma_split3_length l i; length c > 0 ==> i + 1 < length l /\ hd c == index l (i + 1))) = match i with | 0 -> () | _ -> lemma_split3_r_hd (tl l) (i - 1)
val lemma_split3_r_hd (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (ensures (let a, b, c = split3 l i in lemma_split3_length l i; length c > 0 ==> i + 1 < length l /\ hd c == index l (i + 1))) let rec lemma_split3_r_hd (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (ensures (let a, b, c = split3 l i in lemma_split3_length l i; length c > 0 ==> i + 1 < length l /\ hd c == index l (i + 1))) =
false
null
true
match i with | 0 -> () | _ -> lemma_split3_r_hd (tl l) (i - 1)
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.int", "FStar.List.Pure.Properties.lemma_split3_r_hd", "FStar.List.Tot.Base.tl", "Prims.op_Subtraction", "Prims.unit", "Prims.l_True", "Prims.squash", "Prims.l_imp", "Prims.op_GreaterThan", "Prims.l_and", "Prims.op_Addition", "Prims.eq2", "FStar.List.Tot.Base.hd", "FStar.List.Tot.Base.index", "FStar.List.Pure.Properties.lemma_split3_length", "FStar.Pervasives.Native.tuple3", "FStar.List.Tot.Base.split3", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1) (** Doing an [index] on the left-part of a [splitAt] is same as doing it on the original list *) let rec lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) = match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1) (** Doing an [index] on the right-part of a [splitAt] is same as doing it on the original list, but shifted *) let rec lemma_splitAt_reindex_right (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) = match i with | 0 -> () | _ -> lemma_splitAt_reindex_right (i - 1) (tl l) j (** Properties of split3 *) (** The 3 pieces returned via [split3] can be joined together via an [append] and a [cons] *) let lemma_split3_append (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in l == append a (b :: c))) = lemma_splitAt_append n l (** The middle element returned via [split3] is the [n]th [index]ed element *) let lemma_split3_index (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in b == index l n)) = lemma_splitAt_index_hd n l (** The lengths of the left and right parts of a [split3] are as expected. *) let lemma_split3_length (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in length a = n /\ length c = length l - n - 1)) = splitAt_length n l (** If we [split3] on lists with the same left prefix, we get the same element and left prefix. *) let lemma_split3_on_same_leftprefix (#t:Type) (l1 l2:list t) (n:nat{n < length l1 /\ n < length l2}) : Lemma (requires (fst (splitAt (n+1) l1) == fst (splitAt (n+1) l2))) (ensures (let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in a1 == a2 /\ b1 == b2)) = let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in lemma_split3_append l1 n; lemma_split3_append l2 n; lemma_split3_length l1 n; lemma_split3_length l2 n; append_l_cons b1 c1 a1; append_l_cons b2 c2 a2; // assert ((a1 @ [b1]) @ c1 == l1); // assert ((a2 @ [b2]) @ c2 == l2); let x1, y1 = splitAt (n+1) l1 in let x2, y2 = splitAt (n+1) l2 in lemma_splitAt_append (n+1) l1; lemma_splitAt_append (n+1) l2; splitAt_length (n+1) l1; splitAt_length (n+1) l2; // assert (x1 @ y1 == (a1 @ [b1]) @ c1); // assert (x2 @ y2 == (a2 @ [b2]) @ c2); append_length_inv_head x1 y1 (append a1 [b1]) c1; append_length_inv_head x2 y2 (append a2 [b2]) c2; // assert (a1 @ [b1] == a2 @ [b2]); append_length_inv_tail a1 [b1] a2 [b2]; // assert (a1 == a2 /\ b1 == b2); () (** If we perform an [unsnoc] on a list, then the left part is the same as an [append]+[cons] on the list after [split3]. *) let rec lemma_split3_unsnoc (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires (n <> length l - 1)) (ensures ( let a, b, c = split3 l n in lemma_split3_length l n; length c > 0 /\ ( let xs, x = unsnoc l in let ys, y = unsnoc c in append a (b :: ys) == xs))) = match n with | 0 -> () | _ -> lemma_split3_unsnoc (tl l) (n-1) (** Doing [unsnoc] and [split3] in either order leads to the same left part, and element. *) let lemma_unsnoc_split3 (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (requires (i <> length l - 1)) (ensures ( let xs, x = unsnoc l in i < length xs /\ ( let a0, b0, c0 = split3 l i in let a1, b1, c1 = split3 xs i in a0 == a1 /\ b0 == b1))) = let xs, x = unsnoc l in lemma_unsnoc_length l; let a0, b0, c0 = split3 l i in let a1, b1, c1 = split3 xs i in splitAt_length_total xs; // assert (fst (splitAt (length xs) xs) == xs); // assert (fst (splitAt (length xs) xs) == fst (splitAt (length xs) l)); // assert (i+1 <= length xs); lemma_splitAt_shorten_left xs l (length xs) (i+1); // assert (fst (splitAt (i+1) xs) == fst (splitAt (i+1) l)); lemma_split3_on_same_leftprefix l xs i (** The head of the right side of a [split3] can be [index]ed from original list. *) let rec lemma_split3_r_hd (#t:Type) (l:list t) (i:nat{i < length l}) : Lemma (ensures (let a, b, c = split3 l i in lemma_split3_length l i;
false
false
FStar.List.Pure.Properties.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 lemma_split3_r_hd (#t: Type) (l: list t) (i: nat{i < length l}) : Lemma (ensures (let a, b, c = split3 l i in lemma_split3_length l i; length c > 0 ==> i + 1 < length l /\ hd c == index l (i + 1)))
[ "recursion" ]
FStar.List.Pure.Properties.lemma_split3_r_hd
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> i: Prims.nat{i < FStar.List.Tot.Base.length l} -> FStar.Pervasives.Lemma (ensures (let _ = FStar.List.Tot.Base.split3 l i in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ _ _ c = _ in FStar.List.Pure.Properties.lemma_split3_length l i; FStar.List.Tot.Base.length c > 0 ==> i + 1 < FStar.List.Tot.Base.length l /\ FStar.List.Tot.Base.hd c == FStar.List.Tot.Base.index l (i + 1)) <: Type0))
{ "end_col": 41, "end_line": 275, "start_col": 2, "start_line": 273 }
FStar.Pervasives.Lemma
val lemma_split3_unsnoc (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires (n <> length l - 1)) (ensures (let a, b, c = split3 l n in lemma_split3_length l n; length c > 0 /\ (let xs, x = unsnoc l in let ys, y = unsnoc c in append a (b :: ys) == xs)))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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 lemma_split3_unsnoc (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires (n <> length l - 1)) (ensures ( let a, b, c = split3 l n in lemma_split3_length l n; length c > 0 /\ ( let xs, x = unsnoc l in let ys, y = unsnoc c in append a (b :: ys) == xs))) = match n with | 0 -> () | _ -> lemma_split3_unsnoc (tl l) (n-1)
val lemma_split3_unsnoc (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires (n <> length l - 1)) (ensures (let a, b, c = split3 l n in lemma_split3_length l n; length c > 0 /\ (let xs, x = unsnoc l in let ys, y = unsnoc c in append a (b :: ys) == xs))) let rec lemma_split3_unsnoc (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires (n <> length l - 1)) (ensures (let a, b, c = split3 l n in lemma_split3_length l n; length c > 0 /\ (let xs, x = unsnoc l in let ys, y = unsnoc c in append a (b :: ys) == xs))) =
false
null
true
match n with | 0 -> () | _ -> lemma_split3_unsnoc (tl l) (n - 1)
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.int", "FStar.List.Pure.Properties.lemma_split3_unsnoc", "FStar.List.Tot.Base.tl", "Prims.op_Subtraction", "Prims.unit", "Prims.op_disEquality", "Prims.squash", "Prims.l_and", "Prims.op_GreaterThan", "Prims.eq2", "FStar.List.Tot.Base.append", "Prims.Cons", "Prims.logical", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.unsnoc", "FStar.List.Pure.Properties.lemma_split3_length", "FStar.Pervasives.Native.tuple3", "FStar.List.Tot.Base.split3", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1) (** Doing an [index] on the left-part of a [splitAt] is same as doing it on the original list *) let rec lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) = match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1) (** Doing an [index] on the right-part of a [splitAt] is same as doing it on the original list, but shifted *) let rec lemma_splitAt_reindex_right (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) = match i with | 0 -> () | _ -> lemma_splitAt_reindex_right (i - 1) (tl l) j (** Properties of split3 *) (** The 3 pieces returned via [split3] can be joined together via an [append] and a [cons] *) let lemma_split3_append (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in l == append a (b :: c))) = lemma_splitAt_append n l (** The middle element returned via [split3] is the [n]th [index]ed element *) let lemma_split3_index (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in b == index l n)) = lemma_splitAt_index_hd n l (** The lengths of the left and right parts of a [split3] are as expected. *) let lemma_split3_length (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in length a = n /\ length c = length l - n - 1)) = splitAt_length n l (** If we [split3] on lists with the same left prefix, we get the same element and left prefix. *) let lemma_split3_on_same_leftprefix (#t:Type) (l1 l2:list t) (n:nat{n < length l1 /\ n < length l2}) : Lemma (requires (fst (splitAt (n+1) l1) == fst (splitAt (n+1) l2))) (ensures (let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in a1 == a2 /\ b1 == b2)) = let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in lemma_split3_append l1 n; lemma_split3_append l2 n; lemma_split3_length l1 n; lemma_split3_length l2 n; append_l_cons b1 c1 a1; append_l_cons b2 c2 a2; // assert ((a1 @ [b1]) @ c1 == l1); // assert ((a2 @ [b2]) @ c2 == l2); let x1, y1 = splitAt (n+1) l1 in let x2, y2 = splitAt (n+1) l2 in lemma_splitAt_append (n+1) l1; lemma_splitAt_append (n+1) l2; splitAt_length (n+1) l1; splitAt_length (n+1) l2; // assert (x1 @ y1 == (a1 @ [b1]) @ c1); // assert (x2 @ y2 == (a2 @ [b2]) @ c2); append_length_inv_head x1 y1 (append a1 [b1]) c1; append_length_inv_head x2 y2 (append a2 [b2]) c2; // assert (a1 @ [b1] == a2 @ [b2]); append_length_inv_tail a1 [b1] a2 [b2]; // assert (a1 == a2 /\ b1 == b2); () (** If we perform an [unsnoc] on a list, then the left part is the same as an [append]+[cons] on the list after [split3]. *) let rec lemma_split3_unsnoc (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires (n <> length l - 1)) (ensures ( let a, b, c = split3 l n in lemma_split3_length l n; length c > 0 /\ ( let xs, x = unsnoc l in let ys, y = unsnoc c in
false
false
FStar.List.Pure.Properties.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 lemma_split3_unsnoc (#t: Type) (l: list t) (n: nat{n < length l}) : Lemma (requires (n <> length l - 1)) (ensures (let a, b, c = split3 l n in lemma_split3_length l n; length c > 0 /\ (let xs, x = unsnoc l in let ys, y = unsnoc c in append a (b :: ys) == xs)))
[ "recursion" ]
FStar.List.Pure.Properties.lemma_split3_unsnoc
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l: Prims.list t -> n: Prims.nat{n < FStar.List.Tot.Base.length l} -> FStar.Pervasives.Lemma (requires n <> FStar.List.Tot.Base.length l - 1) (ensures (let _ = FStar.List.Tot.Base.split3 l n in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ a b c = _ in FStar.List.Pure.Properties.lemma_split3_length l n; FStar.List.Tot.Base.length c > 0 /\ (let _ = FStar.List.Tot.Base.unsnoc l in (let FStar.Pervasives.Native.Mktuple2 #_ #_ xs _ = _ in let _ = FStar.List.Tot.Base.unsnoc c in (let FStar.Pervasives.Native.Mktuple2 #_ #_ ys _ = _ in a @ b :: ys == xs) <: Prims.logical) <: Prims.logical)) <: Type0))
{ "end_col": 41, "end_line": 241, "start_col": 2, "start_line": 239 }
FStar.Pervasives.Lemma
val lemma_split3_on_same_leftprefix (#t: Type) (l1 l2: list t) (n: nat{n < length l1 /\ n < length l2}) : Lemma (requires (fst (splitAt (n + 1) l1) == fst (splitAt (n + 1) l2))) (ensures (let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in a1 == a2 /\ b1 == b2))
[ { "abbrev": false, "full_module": "FStar.List.Tot.Properties", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot.Base", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Pure", "short_module": null }, { "abbrev": false, "full_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_split3_on_same_leftprefix (#t:Type) (l1 l2:list t) (n:nat{n < length l1 /\ n < length l2}) : Lemma (requires (fst (splitAt (n+1) l1) == fst (splitAt (n+1) l2))) (ensures (let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in a1 == a2 /\ b1 == b2)) = let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in lemma_split3_append l1 n; lemma_split3_append l2 n; lemma_split3_length l1 n; lemma_split3_length l2 n; append_l_cons b1 c1 a1; append_l_cons b2 c2 a2; // assert ((a1 @ [b1]) @ c1 == l1); // assert ((a2 @ [b2]) @ c2 == l2); let x1, y1 = splitAt (n+1) l1 in let x2, y2 = splitAt (n+1) l2 in lemma_splitAt_append (n+1) l1; lemma_splitAt_append (n+1) l2; splitAt_length (n+1) l1; splitAt_length (n+1) l2; // assert (x1 @ y1 == (a1 @ [b1]) @ c1); // assert (x2 @ y2 == (a2 @ [b2]) @ c2); append_length_inv_head x1 y1 (append a1 [b1]) c1; append_length_inv_head x2 y2 (append a2 [b2]) c2; // assert (a1 @ [b1] == a2 @ [b2]); append_length_inv_tail a1 [b1] a2 [b2]; // assert (a1 == a2 /\ b1 == b2); ()
val lemma_split3_on_same_leftprefix (#t: Type) (l1 l2: list t) (n: nat{n < length l1 /\ n < length l2}) : Lemma (requires (fst (splitAt (n + 1) l1) == fst (splitAt (n + 1) l2))) (ensures (let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in a1 == a2 /\ b1 == b2)) let lemma_split3_on_same_leftprefix (#t: Type) (l1 l2: list t) (n: nat{n < length l1 /\ n < length l2}) : Lemma (requires (fst (splitAt (n + 1) l1) == fst (splitAt (n + 1) l2))) (ensures (let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in a1 == a2 /\ b1 == b2)) =
false
null
true
let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in lemma_split3_append l1 n; lemma_split3_append l2 n; lemma_split3_length l1 n; lemma_split3_length l2 n; append_l_cons b1 c1 a1; append_l_cons b2 c2 a2; let x1, y1 = splitAt (n + 1) l1 in let x2, y2 = splitAt (n + 1) l2 in lemma_splitAt_append (n + 1) l1; lemma_splitAt_append (n + 1) l2; splitAt_length (n + 1) l1; splitAt_length (n + 1) l2; append_length_inv_head x1 y1 (append a1 [b1]) c1; append_length_inv_head x2 y2 (append a2 [b2]) c2; append_length_inv_tail a1 [b1] a2 [b2]; ()
{ "checked_file": "FStar.List.Pure.Properties.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.Properties.fst.checked", "FStar.List.Tot.Base.fst.checked", "FStar.List.Pure.Base.fst.checked" ], "interface_file": false, "source_file": "FStar.List.Pure.Properties.fst" }
[ "lemma" ]
[ "Prims.list", "Prims.nat", "Prims.l_and", "Prims.b2t", "Prims.op_LessThan", "FStar.List.Tot.Base.length", "Prims.unit", "FStar.List.Tot.Properties.append_length_inv_tail", "Prims.Cons", "Prims.Nil", "FStar.List.Tot.Properties.append_length_inv_head", "FStar.List.Tot.Base.append", "FStar.List.Pure.Properties.splitAt_length", "Prims.op_Addition", "FStar.List.Pure.Properties.lemma_splitAt_append", "FStar.Pervasives.Native.tuple2", "FStar.List.Tot.Base.splitAt", "FStar.List.Tot.Properties.append_l_cons", "FStar.List.Pure.Properties.lemma_split3_length", "FStar.List.Pure.Properties.lemma_split3_append", "FStar.Pervasives.Native.tuple3", "FStar.List.Tot.Base.split3", "Prims.eq2", "FStar.Pervasives.Native.fst", "Prims.squash", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.List.Pure.Properties open FStar.List.Tot.Base open FStar.List.Pure.Base open FStar.List.Tot.Properties (** Properties of splitAt *) let rec splitAt_length (#a:Type) (n:nat) (l:list a) : Lemma (requires True) (ensures begin let l_1, l_2 = splitAt n l in if length l < n then length l_1 == length l /\ length l_2 == 0 else length l_1 == n /\ length l_2 = length l - n end) (decreases n) = if n = 0 then () else match l with | [] -> () | _::xs -> splitAt_length (n-1) xs let rec splitAt_assoc (#a:Type) (n1 n2:nat) (l:list a) : Lemma (requires True) (ensures begin let l1, l2 = splitAt n1 l in let l2, l3 = splitAt n2 l2 in let l1', l2' = splitAt (n1+n2) l in l1' == l1 @ l2 /\ l2' == l3 end) (decreases n1) = if n1 = 0 then () else match l with | [] -> () | x :: xs -> splitAt_assoc (n1-1) n2 xs let rec splitAt_length_total (#a:Type) (l:list a) : Lemma (requires True) (ensures (splitAt (length l) l == (l, []))) (decreases l) = match l with | [] -> () | x :: xs -> splitAt_length_total xs (** If we [append] the two lists produced using a [splitAt], then we get back the original list *) let rec lemma_splitAt_append (#a:Type) (n:nat) (l:list a) : Lemma (requires n <= length l) (ensures (let l1, l2 = splitAt n l in append l1 l2 == l /\ length l1 = n)) = match n with | 0 -> () | _ -> match l with | [] -> () | x :: xs -> lemma_splitAt_append (n-1) xs (** If we [splitAt] the point at which two lists have been [append]ed, then we get back the original lists. *) let rec lemma_append_splitAt (#t:Type) (l1 l2:list t) : Lemma (ensures (splitAt (length l1) (append l1 l2) == (l1, l2))) = match l1 with | [] -> () | _ -> lemma_append_splitAt (tl l1) l2 (** Fully characterize behavior of [splitAt] in terms of more standard list concepts *) let lemma_splitAt (#t: Type) (l l1 l2:list t) (n:nat{n <= length l}) : Lemma (splitAt n l == (l1, l2) <==> l == l1 @ l2 /\ length l1 = n) = lemma_splitAt_append n l; lemma_append_splitAt l1 l2 (** The [hd] of the second list returned via [splitAt] is the [n]th element of the original list *) let rec lemma_splitAt_index_hd (#t:Type) (n:nat) (l:list t) : Lemma (requires (n < length l)) (ensures (let l1, l2 = splitAt n l in splitAt_length n l; length l2 > 0 /\ hd l2 == index l n)) = let x :: xs = l in match n with | 0 -> () | _ -> lemma_splitAt_index_hd (n - 1) (tl l) (** If two lists have the same left prefix, then shorter left prefixes are also the same. *) let rec lemma_splitAt_shorten_left (#t:Type) (l1 l2:list t) (i:nat{i <= length l1 /\ i <= length l2}) (j:nat{j <= i}) : Lemma (requires (fst (splitAt i l1) == fst (splitAt i l2))) (ensures (fst (splitAt j l1) == fst (splitAt j l2))) = match j with | 0 -> () | _ -> lemma_splitAt_shorten_left (tl l1) (tl l2) (i-1) (j-1) (** Doing an [index] on the left-part of a [splitAt] is same as doing it on the original list *) let rec lemma_splitAt_reindex_left (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j < i) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length left /\ index left j == index l j)) = match i, j with | 1, _ | _, 0 -> () | _ -> lemma_splitAt_reindex_left (i - 1) (tl l) (j - 1) (** Doing an [index] on the right-part of a [splitAt] is same as doing it on the original list, but shifted *) let rec lemma_splitAt_reindex_right (#t:Type) (i:nat) (l:list t) (j:nat) : Lemma (requires i <= length l /\ j + i < length l) (ensures ( let left, right = splitAt i l in splitAt_length i l; j < length right /\ index right j == index l (j + i))) = match i with | 0 -> () | _ -> lemma_splitAt_reindex_right (i - 1) (tl l) j (** Properties of split3 *) (** The 3 pieces returned via [split3] can be joined together via an [append] and a [cons] *) let lemma_split3_append (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in l == append a (b :: c))) = lemma_splitAt_append n l (** The middle element returned via [split3] is the [n]th [index]ed element *) let lemma_split3_index (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in b == index l n)) = lemma_splitAt_index_hd n l (** The lengths of the left and right parts of a [split3] are as expected. *) let lemma_split3_length (#t:Type) (l:list t) (n:nat{n < length l}) : Lemma (requires True) (ensures ( let a, b, c = split3 l n in length a = n /\ length c = length l - n - 1)) = splitAt_length n l (** If we [split3] on lists with the same left prefix, we get the same element and left prefix. *) let lemma_split3_on_same_leftprefix (#t:Type) (l1 l2:list t) (n:nat{n < length l1 /\ n < length l2}) : Lemma (requires (fst (splitAt (n+1) l1) == fst (splitAt (n+1) l2))) (ensures (let a1, b1, c1 = split3 l1 n in
false
false
FStar.List.Pure.Properties.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 lemma_split3_on_same_leftprefix (#t: Type) (l1 l2: list t) (n: nat{n < length l1 /\ n < length l2}) : Lemma (requires (fst (splitAt (n + 1) l1) == fst (splitAt (n + 1) l2))) (ensures (let a1, b1, c1 = split3 l1 n in let a2, b2, c2 = split3 l2 n in a1 == a2 /\ b1 == b2))
[]
FStar.List.Pure.Properties.lemma_split3_on_same_leftprefix
{ "file_name": "ulib/FStar.List.Pure.Properties.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
l1: Prims.list t -> l2: Prims.list t -> n: Prims.nat{n < FStar.List.Tot.Base.length l1 /\ n < FStar.List.Tot.Base.length l2} -> FStar.Pervasives.Lemma (requires FStar.Pervasives.Native.fst (FStar.List.Tot.Base.splitAt (n + 1) l1) == FStar.Pervasives.Native.fst (FStar.List.Tot.Base.splitAt (n + 1) l2)) (ensures (let _ = FStar.List.Tot.Base.split3 l1 n in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ a1 b1 _ = _ in let _ = FStar.List.Tot.Base.split3 l2 n in (let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ a2 b2 _ = _ in a1 == a2 /\ b1 == b2) <: Type0) <: Type0))
{ "end_col": 4, "end_line": 224, "start_col": 38, "start_line": 200 }
Prims.Tot
val table_inv_w4:BE.table_inv_t U64 12ul 16ul
[ { "abbrev": false, "full_module": "Hacl.P256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Field", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let table_inv_w4 : BE.table_inv_t U64 12ul 16ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len
val table_inv_w4:BE.table_inv_t U64 12ul 16ul let table_inv_w4:BE.table_inv_t U64 12ul 16ul =
false
null
false
[@@ inline_let ]let len = 12ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_p256_concrete_ops in [@@ inline_let ]let l = 4ul in [@@ inline_let ]let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len
{ "checked_file": "Hacl.Impl.P256.PointMul.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.P256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "Hacl.Impl.P256.Field.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.P256.PointMul.fst" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.table_inv_precomp", "Lib.IntTypes.U64", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.P256.Group.mk_p256_concrete_ops" ]
[]
module Hacl.Impl.P256.PointMul open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Field open Hacl.Impl.P256.Point module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.P256 module SL = Spec.P256.Lemmas include Hacl.Impl.P256.Group include Hacl.P256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract
false
false
Hacl.Impl.P256.PointMul.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 table_inv_w4:BE.table_inv_t U64 12ul 16ul
[]
Hacl.Impl.P256.PointMul.table_inv_w4
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Exponentiation.table_inv_t Lib.IntTypes.U64 (FStar.UInt32.uint_to_t 12 <: FStar.UInt32.t) (FStar.UInt32.uint_to_t 16 <: FStar.UInt32.t)
{ "end_col": 48, "end_line": 38, "start_col": 2, "start_line": 33 }
Prims.Tot
val table_inv_w5:BE.table_inv_t U64 12ul 32ul
[ { "abbrev": false, "full_module": "Hacl.P256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Field", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let table_inv_w5 : BE.table_inv_t U64 12ul 32ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len
val table_inv_w5:BE.table_inv_t U64 12ul 32ul let table_inv_w5:BE.table_inv_t U64 12ul 32ul =
false
null
false
[@@ inline_let ]let len = 12ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_p256_concrete_ops in [@@ inline_let ]let l = 5ul in [@@ inline_let ]let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len
{ "checked_file": "Hacl.Impl.P256.PointMul.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.P256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "Hacl.Impl.P256.Field.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.P256.PointMul.fst" }
[ "total" ]
[ "Hacl.Impl.Exponentiation.table_inv_precomp", "Lib.IntTypes.U64", "Prims.unit", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Lib.IntTypes.U32", "Prims.pow2", "Lib.IntTypes.v", "Lib.IntTypes.PUB", "FStar.UInt32.t", "FStar.UInt32.__uint_to_t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.P256.Group.mk_p256_concrete_ops" ]
[]
module Hacl.Impl.P256.PointMul open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Field open Hacl.Impl.P256.Point module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.P256 module SL = Spec.P256.Lemmas include Hacl.Impl.P256.Group include Hacl.P256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 12ul 16ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract
false
false
Hacl.Impl.P256.PointMul.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 table_inv_w5:BE.table_inv_t U64 12ul 32ul
[]
Hacl.Impl.P256.PointMul.table_inv_w5
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Exponentiation.table_inv_t Lib.IntTypes.U64 (FStar.UInt32.uint_to_t 12 <: FStar.UInt32.t) (FStar.UInt32.uint_to_t 32 <: FStar.UInt32.t)
{ "end_col": 48, "end_line": 49, "start_col": 2, "start_line": 43 }
FStar.HyperStack.ST.Stack
val point_mul: res:point -> scalar:felem -> p:point -> Stack unit (requires fun h -> live h p /\ live h res /\ live h scalar /\ disjoint p res /\ disjoint scalar res /\ disjoint p scalar /\ point_inv h p /\ as_nat h scalar < S.order) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ point_inv h1 res /\ S.to_aff_point (from_mont_point (as_point_nat h1 res)) == S.to_aff_point (S.point_mul (as_nat h0 scalar) (from_mont_point (as_point_nat h0 p))))
[ { "abbrev": false, "full_module": "Hacl.P256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Field", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul res scalar p = let h0 = ST.get () in SE.exp_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 p)) 256 (as_nat h0 scalar) 4; BE.lexp_fw_consttime 12ul 0ul mk_p256_concrete_ops 4ul (null uint64) p 4ul 256ul scalar res
val point_mul: res:point -> scalar:felem -> p:point -> Stack unit (requires fun h -> live h p /\ live h res /\ live h scalar /\ disjoint p res /\ disjoint scalar res /\ disjoint p scalar /\ point_inv h p /\ as_nat h scalar < S.order) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ point_inv h1 res /\ S.to_aff_point (from_mont_point (as_point_nat h1 res)) == S.to_aff_point (S.point_mul (as_nat h0 scalar) (from_mont_point (as_point_nat h0 p)))) let point_mul res scalar p =
true
null
false
let h0 = ST.get () in SE.exp_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 p)) 256 (as_nat h0 scalar) 4; BE.lexp_fw_consttime 12ul 0ul mk_p256_concrete_ops 4ul (null uint64) p 4ul 256ul scalar res
{ "checked_file": "Hacl.Impl.P256.PointMul.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.P256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "Hacl.Impl.P256.Field.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.P256.PointMul.fst" }
[]
[ "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Bignum.felem", "Hacl.Impl.Exponentiation.lexp_fw_consttime", "Lib.IntTypes.U64", "FStar.UInt32.__uint_to_t", "Hacl.Impl.P256.Group.mk_p256_concrete_ops", "Lib.Buffer.null", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Prims.unit", "Spec.Exponentiation.exp_fw_lemma", "Spec.P256.PointOps.proj_point", "Spec.P256.mk_p256_concrete_ops", "Hacl.Impl.P256.Point.from_mont_point", "Hacl.Impl.P256.Point.as_point_nat", "Hacl.Impl.P256.Bignum.as_nat", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get" ]
[]
module Hacl.Impl.P256.PointMul open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Field open Hacl.Impl.P256.Point module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.P256 module SL = Spec.P256.Lemmas include Hacl.Impl.P256.Group include Hacl.P256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 12ul 16ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 12ul 32ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len
false
false
Hacl.Impl.P256.PointMul.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 point_mul: res:point -> scalar:felem -> p:point -> Stack unit (requires fun h -> live h p /\ live h res /\ live h scalar /\ disjoint p res /\ disjoint scalar res /\ disjoint p scalar /\ point_inv h p /\ as_nat h scalar < S.order) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ point_inv h1 res /\ S.to_aff_point (from_mont_point (as_point_nat h1 res)) == S.to_aff_point (S.point_mul (as_nat h0 scalar) (from_mont_point (as_point_nat h0 p))))
[]
Hacl.Impl.P256.PointMul.point_mul
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
res: Hacl.Impl.P256.Point.point -> scalar: Hacl.Impl.P256.Bignum.felem -> p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 93, "end_line": 57, "start_col": 28, "start_line": 53 }
FStar.Pervasives.Lemma
val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.order} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b)))
[ { "abbrev": false, "full_module": "Hacl.P256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Field", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_exp_four_fw_local b = let cm = S.mk_p256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_p256_concrete_ops S.base_point 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b))
val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.order} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b =
false
null
true
let cm = S.mk_p256_comm_monoid in let b0, b1, b2, b3 = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_p256_concrete_ops S.base_point 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b))
{ "checked_file": "Hacl.Impl.P256.PointMul.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.P256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "Hacl.Impl.P256.Field.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.P256.PointMul.fst" }
[ "lemma" ]
[ "Hacl.Spec.Bignum.Definitions.lbignum", "Lib.IntTypes.U64", "Prims.b2t", "Prims.op_LessThan", "Hacl.Spec.Bignum.Definitions.bn_v", "Spec.P256.PointOps.order", "Prims.int", "Prims._assert", "Prims.eq2", "Spec.P256.PointOps.aff_point", "Spec.P256.PointOps.to_aff_point", "Spec.P256.point_mul_g", "Lib.Exponentiation.Definition.pow", "Hacl.P256.PrecompTable.g_aff", "Prims.unit", "Lib.Exponentiation.exp_fw_lemma", "Spec.Exponentiation.exp_fw_lemma", "Spec.P256.PointOps.proj_point", "Spec.P256.mk_p256_concrete_ops", "Spec.P256.PointOps.base_point", "Hacl.Spec.PrecompBaseTable256.lemma_point_mul_base_precomp4", "Hacl.Spec.PrecompBaseTable256.exp_as_exp_four_nat256_precomp", "Lib.Exponentiation.exp_four_fw", "Hacl.P256.PrecompTable.g_pow2_64", "Hacl.P256.PrecompTable.g_pow2_128", "Hacl.P256.PrecompTable.g_pow2_192", "FStar.Pervasives.Native.tuple4", "Hacl.Spec.PrecompBaseTable256.decompose_nat256_as_four_u64", "Lib.Exponentiation.Definition.comm_monoid", "Spec.P256.mk_p256_comm_monoid" ]
[]
module Hacl.Impl.P256.PointMul open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Field open Hacl.Impl.P256.Point module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.P256 module SL = Spec.P256.Lemmas include Hacl.Impl.P256.Group include Hacl.P256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 12ul 16ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 12ul 32ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len [@CInline] let point_mul res scalar p = let h0 = ST.get () in SE.exp_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 p)) 256 (as_nat h0 scalar) 4; BE.lexp_fw_consttime 12ul 0ul mk_p256_concrete_ops 4ul (null uint64) p 4ul 256ul scalar res val precomp_get_consttime: BE.pow_a_to_small_b_st U64 12ul 0ul mk_p256_concrete_ops 4ul 16ul (BE.table_inv_precomp 12ul 0ul mk_p256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:felem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ as_nat h scalar < S.order /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (as_nat h0 scalar) in S.to_aff_point (from_mont_point (as_point_nat h1 out)) == LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.order} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b)))
false
false
Hacl.Impl.P256.PointMul.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_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.order} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b)))
[]
Hacl.Impl.P256.PointMul.lemma_exp_four_fw_local
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
b: Hacl.Spec.Bignum.Definitions.lbignum Lib.IntTypes.U64 4 {Hacl.Spec.Bignum.Definitions.bn_v b < Spec.P256.PointOps.order} -> FStar.Pervasives.Lemma (ensures (let _ = Hacl.Spec.PrecompBaseTable256.decompose_nat256_as_four_u64 (Hacl.Spec.Bignum.Definitions.bn_v b) in (let FStar.Pervasives.Native.Mktuple4 #_ #_ #_ #_ b0 b1 b2 b3 = _ in Lib.Exponentiation.exp_four_fw Spec.P256.mk_p256_comm_monoid Hacl.P256.PrecompTable.g_aff 64 b0 Hacl.P256.PrecompTable.g_pow2_64 b1 Hacl.P256.PrecompTable.g_pow2_128 b2 Hacl.P256.PrecompTable.g_pow2_192 b3 4 == Spec.P256.PointOps.to_aff_point (Spec.P256.point_mul_g (Hacl.Spec.Bignum.Definitions.bn_v b ))) <: Type0))
{ "end_col": 84, "end_line": 160, "start_col": 31, "start_line": 151 }
Prims.Tot
val precomp_get_consttime: BE.pow_a_to_small_b_st U64 12ul 0ul mk_p256_concrete_ops 4ul 16ul (BE.table_inv_precomp 12ul 0ul mk_p256_concrete_ops 4ul 16ul)
[ { "abbrev": false, "full_module": "Hacl.P256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Field", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp
val precomp_get_consttime: BE.pow_a_to_small_b_st U64 12ul 0ul mk_p256_concrete_ops 4ul 16ul (BE.table_inv_precomp 12ul 0ul mk_p256_concrete_ops 4ul 16ul) let precomp_get_consttime ctx a table bits_l tmp =
false
null
false
[@@ inline_let ]let len = 12ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_p256_concrete_ops in [@@ inline_let ]let l = 4ul in [@@ inline_let ]let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp
{ "checked_file": "Hacl.Impl.P256.PointMul.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.P256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "Hacl.Impl.P256.Field.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.P256.PointMul.fst" }
[ "total" ]
[ "Lib.Buffer.lbuffer", "Lib.IntTypes.uint_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.__uint_to_t", "FStar.Ghost.erased", "Lib.Sequence.lseq", "Lib.IntTypes.v", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "Lib.Buffer.clbuffer", "Lib.IntTypes.op_Star_Bang", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Hacl.Impl.Exponentiation.lprecomp_get_consttime", "Prims.unit", "FStar.UInt32.t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.P256.Group.mk_p256_concrete_ops" ]
[]
module Hacl.Impl.P256.PointMul open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Field open Hacl.Impl.P256.Point module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.P256 module SL = Spec.P256.Lemmas include Hacl.Impl.P256.Group include Hacl.P256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 12ul 16ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 12ul 32ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len [@CInline] let point_mul res scalar p = let h0 = ST.get () in SE.exp_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 p)) 256 (as_nat h0 scalar) 4; BE.lexp_fw_consttime 12ul 0ul mk_p256_concrete_ops 4ul (null uint64) p 4ul 256ul scalar res val precomp_get_consttime: BE.pow_a_to_small_b_st U64 12ul 0ul mk_p256_concrete_ops 4ul 16ul (BE.table_inv_precomp 12ul 0ul mk_p256_concrete_ops 4ul 16ul) [@CInline]
false
false
Hacl.Impl.P256.PointMul.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 precomp_get_consttime: BE.pow_a_to_small_b_st U64 12ul 0ul mk_p256_concrete_ops 4ul 16ul (BE.table_inv_precomp 12ul 0ul mk_p256_concrete_ops 4ul 16ul)
[]
Hacl.Impl.P256.PointMul.precomp_get_consttime
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Hacl.Impl.Exponentiation.pow_a_to_small_b_st Lib.IntTypes.U64 12ul 0ul Hacl.Impl.P256.Group.mk_p256_concrete_ops 4ul 16ul (Hacl.Impl.Exponentiation.table_inv_precomp 12ul 0ul Hacl.Impl.P256.Group.mk_p256_concrete_ops 4ul 16ul)
{ "end_col": 76, "end_line": 70, "start_col": 2, "start_line": 64 }
FStar.HyperStack.ST.Stack
val point_mul_g_double_vartime_noalloc: out:point -> scalar1:felem -> q1:point -> scalar2:felem -> q2:point -> table2:lbuffer uint64 (32ul *! 12ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ as_nat h scalar1 < S.order /\ as_nat h scalar2 < S.order /\ point_inv h q1 /\ from_mont_point (as_point_nat h q1) == S.base_point /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ refl (as_seq h1 out) == S.to_aff_point (S.point_mul_double_g (as_nat h0 scalar1) (as_nat h0 scalar2) (from_mont_point (as_point_nat h0 q2))))
[ { "abbrev": false, "full_module": "Hacl.P256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Field", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2 = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in [@inline_let] let bLen = 4ul in [@inline_let] let bBits = 256ul in assert_norm (pow2 (v l) == v table_len); let h0 = ST.get () in recall_contents precomp_basepoint_table_w5 precomp_basepoint_table_lseq_w5; let h1 = ST.get () in precomp_basepoint_table_lemma_w5 (); assert (table_inv_w5 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w5)); assert (table_inv_w5 (as_seq h1 q2) (as_seq h1 table2)); ME.mk_lexp_double_fw_tables len ctx_len k l table_len table_inv_w5 table_inv_w5 (BE.lprecomp_get_vartime len ctx_len k l table_len) (BE.lprecomp_get_vartime len ctx_len k l table_len) (null uint64) q1 bLen bBits scalar1 q2 scalar2 (to_const precomp_basepoint_table_w5) (to_const table2) out; SE.exp_double_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 q1)) 256 (as_nat h0 scalar1) (from_mont_point (as_point_nat h0 q2)) (as_nat h0 scalar2) 5
val point_mul_g_double_vartime_noalloc: out:point -> scalar1:felem -> q1:point -> scalar2:felem -> q2:point -> table2:lbuffer uint64 (32ul *! 12ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ as_nat h scalar1 < S.order /\ as_nat h scalar2 < S.order /\ point_inv h q1 /\ from_mont_point (as_point_nat h q1) == S.base_point /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ refl (as_seq h1 out) == S.to_aff_point (S.point_mul_double_g (as_nat h0 scalar1) (as_nat h0 scalar2) (from_mont_point (as_point_nat h0 q2)))) let point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2 =
true
null
false
[@@ inline_let ]let len = 12ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_p256_concrete_ops in [@@ inline_let ]let l = 5ul in [@@ inline_let ]let table_len = 32ul in [@@ inline_let ]let bLen = 4ul in [@@ inline_let ]let bBits = 256ul in assert_norm (pow2 (v l) == v table_len); let h0 = ST.get () in recall_contents precomp_basepoint_table_w5 precomp_basepoint_table_lseq_w5; let h1 = ST.get () in precomp_basepoint_table_lemma_w5 (); assert (table_inv_w5 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w5)); assert (table_inv_w5 (as_seq h1 q2) (as_seq h1 table2)); ME.mk_lexp_double_fw_tables len ctx_len k l table_len table_inv_w5 table_inv_w5 (BE.lprecomp_get_vartime len ctx_len k l table_len) (BE.lprecomp_get_vartime len ctx_len k l table_len) (null uint64) q1 bLen bBits scalar1 q2 scalar2 (to_const precomp_basepoint_table_w5) (to_const table2) out; SE.exp_double_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 q1)) 256 (as_nat h0 scalar1) (from_mont_point (as_point_nat h0 q2)) (as_nat h0 scalar2) 5
{ "checked_file": "Hacl.Impl.P256.PointMul.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.P256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "Hacl.Impl.P256.Field.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.P256.PointMul.fst" }
[]
[ "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Bignum.felem", "Lib.Buffer.lbuffer", "Lib.IntTypes.uint64", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.UInt32.__uint_to_t", "Spec.Exponentiation.exp_double_fw_lemma", "Spec.P256.PointOps.proj_point", "Spec.P256.mk_p256_concrete_ops", "Hacl.Impl.P256.Point.from_mont_point", "Hacl.Impl.P256.Point.as_point_nat", "Hacl.Impl.P256.Bignum.as_nat", "Prims.unit", "Hacl.Impl.MultiExponentiation.mk_lexp_double_fw_tables", "Lib.IntTypes.U64", "Hacl.Impl.P256.PointMul.table_inv_w5", "Hacl.Impl.Exponentiation.lprecomp_get_vartime", "Lib.Buffer.null", "Lib.Buffer.MUT", "Lib.Buffer.to_const", "Lib.Buffer.CONST", "Hacl.P256.PrecompTable.precomp_basepoint_table_w5", "Prims._assert", "Lib.Buffer.as_seq", "Hacl.P256.PrecompTable.precomp_basepoint_table_lemma_w5", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.recall_contents", "Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w5", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.l_or", "Prims.b2t", "Prims.op_GreaterThan", "Lib.IntTypes.range", "Prims.pow2", "Lib.IntTypes.v", "FStar.UInt32.t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.P256.Group.mk_p256_concrete_ops" ]
[]
module Hacl.Impl.P256.PointMul open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Field open Hacl.Impl.P256.Point module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.P256 module SL = Spec.P256.Lemmas include Hacl.Impl.P256.Group include Hacl.P256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 12ul 16ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 12ul 32ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len [@CInline] let point_mul res scalar p = let h0 = ST.get () in SE.exp_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 p)) 256 (as_nat h0 scalar) 4; BE.lexp_fw_consttime 12ul 0ul mk_p256_concrete_ops 4ul (null uint64) p 4ul 256ul scalar res val precomp_get_consttime: BE.pow_a_to_small_b_st U64 12ul 0ul mk_p256_concrete_ops 4ul 16ul (BE.table_inv_precomp 12ul 0ul mk_p256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:felem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ as_nat h scalar < S.order /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (as_nat h0 scalar) in S.to_aff_point (from_mont_point (as_point_nat h1 out)) == LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.order} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b = let cm = S.mk_p256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_p256_concrete_ops S.base_point 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b)) [@CInline] let point_mul_g res scalar = push_frame (); let h0 = ST.get () in let q1 = create_point () in make_base_point q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc res scalar q1 q2 q3 q4; LowStar.Ignore.ignore q1; LowStar.Ignore.ignore q2; LowStar.Ignore.ignore q3; LowStar.Ignore.ignore q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame () //------------------------- inline_for_extraction noextract val point_mul_g_double_vartime_noalloc: out:point -> scalar1:felem -> q1:point -> scalar2:felem -> q2:point -> table2:lbuffer uint64 (32ul *! 12ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ as_nat h scalar1 < S.order /\ as_nat h scalar2 < S.order /\ point_inv h q1 /\ from_mont_point (as_point_nat h q1) == S.base_point /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ refl (as_seq h1 out) == S.to_aff_point (S.point_mul_double_g (as_nat h0 scalar1) (as_nat h0 scalar2) (from_mont_point (as_point_nat h0 q2))))
false
false
Hacl.Impl.P256.PointMul.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 point_mul_g_double_vartime_noalloc: out:point -> scalar1:felem -> q1:point -> scalar2:felem -> q2:point -> table2:lbuffer uint64 (32ul *! 12ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ as_nat h scalar1 < S.order /\ as_nat h scalar2 < S.order /\ point_inv h q1 /\ from_mont_point (as_point_nat h q1) == S.base_point /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ refl (as_seq h1 out) == S.to_aff_point (S.point_mul_double_g (as_nat h0 scalar1) (as_nat h0 scalar2) (from_mont_point (as_point_nat h0 q2))))
[]
Hacl.Impl.P256.PointMul.point_mul_g_double_vartime_noalloc
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Impl.P256.Point.point -> scalar1: Hacl.Impl.P256.Bignum.felem -> q1: Hacl.Impl.P256.Point.point -> scalar2: Hacl.Impl.P256.Bignum.felem -> q2: Hacl.Impl.P256.Point.point -> table2: Lib.Buffer.lbuffer Lib.IntTypes.uint64 (32ul *! 12ul) -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 64, "end_line": 234, "start_col": 2, "start_line": 209 }
FStar.HyperStack.ST.Stack
val point_mul_g_noalloc: out:point -> scalar:felem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ as_nat h scalar < S.order /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (as_nat h0 scalar) in S.to_aff_point (from_mont_point (as_point_nat h1 out)) == LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4))
[ { "abbrev": false, "full_module": "Hacl.P256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Field", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out
val point_mul_g_noalloc: out:point -> scalar:felem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ as_nat h scalar < S.order /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (as_nat h0 scalar) in S.to_aff_point (from_mont_point (as_point_nat h1 out)) == LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 =
true
null
false
[@@ inline_let ]let len = 12ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_p256_concrete_ops in [@@ inline_let ]let l = 4ul in [@@ inline_let ]let table_len = 16ul in [@@ inline_let ]let bLen = 1ul in [@@ inline_let ]let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out
{ "checked_file": "Hacl.Impl.P256.PointMul.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.P256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "Hacl.Impl.P256.Field.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.P256.PointMul.fst" }
[]
[ "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Bignum.felem", "Hacl.Impl.MultiExponentiation.mk_lexp_four_fw_tables", "Lib.IntTypes.U64", "Hacl.Impl.P256.PointMul.table_inv_w4", "Hacl.Impl.P256.PointMul.precomp_get_consttime", "Lib.Buffer.null", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Lib.Buffer.to_const", "Lib.Buffer.CONST", "Hacl.P256.PrecompTable.precomp_basepoint_table_w4", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_w4", "Hacl.P256.PrecompTable.precomp_g_pow2_128_table_w4", "Hacl.P256.PrecompTable.precomp_g_pow2_192_table_w4", "Prims.unit", "Hacl.Spec.PrecompBaseTable256.lemma_decompose_nat256_as_four_u64_lbignum", "Lib.Buffer.as_seq", "Lib.IntTypes.size", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Lib.Buffer.sub", "FStar.UInt32.__uint_to_t", "Prims._assert", "Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lemma_w4", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Lib.Buffer.recall_contents", "Hacl.P256.PrecompTable.precomp_g_pow2_192_table_lseq_w4", "Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lemma_w4", "Hacl.P256.PrecompTable.precomp_g_pow2_128_table_lseq_w4", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lemma_w4", "Hacl.P256.PrecompTable.precomp_g_pow2_64_table_lseq_w4", "Hacl.P256.PrecompTable.precomp_basepoint_table_lemma_w4", "Hacl.P256.PrecompTable.precomp_basepoint_table_lseq_w4", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "Hacl.Impl.P256.Group.mk_p256_concrete_ops" ]
[]
module Hacl.Impl.P256.PointMul open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Field open Hacl.Impl.P256.Point module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.P256 module SL = Spec.P256.Lemmas include Hacl.Impl.P256.Group include Hacl.P256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 12ul 16ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 12ul 32ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len [@CInline] let point_mul res scalar p = let h0 = ST.get () in SE.exp_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 p)) 256 (as_nat h0 scalar) 4; BE.lexp_fw_consttime 12ul 0ul mk_p256_concrete_ops 4ul (null uint64) p 4ul 256ul scalar res val precomp_get_consttime: BE.pow_a_to_small_b_st U64 12ul 0ul mk_p256_concrete_ops 4ul 16ul (BE.table_inv_precomp 12ul 0ul mk_p256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:felem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ as_nat h scalar < S.order /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (as_nat h0 scalar) in S.to_aff_point (from_mont_point (as_point_nat h1 out)) == LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4))
false
false
Hacl.Impl.P256.PointMul.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 point_mul_g_noalloc: out:point -> scalar:felem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ as_nat h scalar < S.order /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (as_nat h0 scalar) in S.to_aff_point (from_mont_point (as_point_nat h1 out)) == LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4))
[]
Hacl.Impl.P256.PointMul.point_mul_g_noalloc
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
out: Hacl.Impl.P256.Point.point -> scalar: Hacl.Impl.P256.Bignum.felem -> q1: Hacl.Impl.P256.Point.point -> q2: Hacl.Impl.P256.Point.point -> q3: Hacl.Impl.P256.Point.point -> q4: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 7, "end_line": 143, "start_col": 2, "start_line": 97 }
FStar.HyperStack.ST.Stack
val point_mul_double_g: res:point -> scalar1:felem -> scalar2:felem -> p:point -> Stack unit (requires fun h -> live h res /\ live h scalar1 /\ live h scalar2 /\ live h p /\ disjoint res scalar1 /\ disjoint res scalar2 /\ disjoint res p /\ disjoint p scalar1 /\ disjoint p scalar2 /\ point_inv h p /\ as_nat h scalar1 < S.order /\ as_nat h scalar2 < S.order) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ point_inv h1 res /\ S.to_aff_point (from_mont_point (as_point_nat h1 res)) == S.to_aff_point (S.point_mul_double_g (as_nat h0 scalar1) (as_nat h0 scalar2) (from_mont_point (as_point_nat h0 p))))
[ { "abbrev": false, "full_module": "Hacl.P256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Field", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul_double_g res scalar1 scalar2 q2 = push_frame (); [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let table_len = 32ul in assert_norm (pow2 5 == v table_len); let q1 = create_point () in make_base_point q1; let table2 = create (table_len *! len) (u64 0) in PT.lprecomp_table len ctx_len k (null uint64) q2 table_len table2; let h = ST.get () in assert (table_inv_w5 (as_seq h q2) (as_seq h table2)); point_mul_g_double_vartime_noalloc res scalar1 q1 scalar2 q2 table2; pop_frame ()
val point_mul_double_g: res:point -> scalar1:felem -> scalar2:felem -> p:point -> Stack unit (requires fun h -> live h res /\ live h scalar1 /\ live h scalar2 /\ live h p /\ disjoint res scalar1 /\ disjoint res scalar2 /\ disjoint res p /\ disjoint p scalar1 /\ disjoint p scalar2 /\ point_inv h p /\ as_nat h scalar1 < S.order /\ as_nat h scalar2 < S.order) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ point_inv h1 res /\ S.to_aff_point (from_mont_point (as_point_nat h1 res)) == S.to_aff_point (S.point_mul_double_g (as_nat h0 scalar1) (as_nat h0 scalar2) (from_mont_point (as_point_nat h0 p)))) let point_mul_double_g res scalar1 scalar2 q2 =
true
null
false
push_frame (); [@@ inline_let ]let len = 12ul in [@@ inline_let ]let ctx_len = 0ul in [@@ inline_let ]let k = mk_p256_concrete_ops in [@@ inline_let ]let table_len = 32ul in assert_norm (pow2 5 == v table_len); let q1 = create_point () in make_base_point q1; let table2 = create (table_len *! len) (u64 0) in PT.lprecomp_table len ctx_len k (null uint64) q2 table_len table2; let h = ST.get () in assert (table_inv_w5 (as_seq h q2) (as_seq h table2)); point_mul_g_double_vartime_noalloc res scalar1 q1 scalar2 q2 table2; pop_frame ()
{ "checked_file": "Hacl.Impl.P256.PointMul.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.P256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "Hacl.Impl.P256.Field.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.P256.PointMul.fst" }
[]
[ "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Bignum.felem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.P256.PointMul.point_mul_g_double_vartime_noalloc", "Prims._assert", "Hacl.Impl.P256.PointMul.table_inv_w5", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "FStar.UInt32.__uint_to_t", "Lib.IntTypes.uint_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "Lib.IntTypes.op_Star_Bang", "Lib.IntTypes.U32", "Lib.IntTypes.PUB", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "Hacl.Impl.PrecompTable.lprecomp_table", "Lib.Buffer.null", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.mul", "Lib.Buffer.create", "Lib.IntTypes.u64", "Lib.Buffer.lbuffer", "Hacl.Impl.P256.Point.make_base_point", "Hacl.Impl.P256.Point.create_point", "FStar.Pervasives.assert_norm", "Prims.eq2", "Prims.int", "Prims.l_or", "Lib.IntTypes.range", "Prims.b2t", "Prims.op_GreaterThan", "Prims.pow2", "Lib.IntTypes.v", "FStar.UInt32.t", "Hacl.Impl.Exponentiation.Definitions.concrete_ops", "FStar.UInt32.uint_to_t", "Hacl.Impl.P256.Group.mk_p256_concrete_ops", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.P256.PointMul open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Field open Hacl.Impl.P256.Point module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.P256 module SL = Spec.P256.Lemmas include Hacl.Impl.P256.Group include Hacl.P256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 12ul 16ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 12ul 32ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len [@CInline] let point_mul res scalar p = let h0 = ST.get () in SE.exp_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 p)) 256 (as_nat h0 scalar) 4; BE.lexp_fw_consttime 12ul 0ul mk_p256_concrete_ops 4ul (null uint64) p 4ul 256ul scalar res val precomp_get_consttime: BE.pow_a_to_small_b_st U64 12ul 0ul mk_p256_concrete_ops 4ul 16ul (BE.table_inv_precomp 12ul 0ul mk_p256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:felem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ as_nat h scalar < S.order /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (as_nat h0 scalar) in S.to_aff_point (from_mont_point (as_point_nat h1 out)) == LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.order} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b = let cm = S.mk_p256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_p256_concrete_ops S.base_point 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b)) [@CInline] let point_mul_g res scalar = push_frame (); let h0 = ST.get () in let q1 = create_point () in make_base_point q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc res scalar q1 q2 q3 q4; LowStar.Ignore.ignore q1; LowStar.Ignore.ignore q2; LowStar.Ignore.ignore q3; LowStar.Ignore.ignore q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame () //------------------------- inline_for_extraction noextract val point_mul_g_double_vartime_noalloc: out:point -> scalar1:felem -> q1:point -> scalar2:felem -> q2:point -> table2:lbuffer uint64 (32ul *! 12ul) -> Stack unit (requires fun h -> live h out /\ live h scalar1 /\ live h q1 /\ live h scalar2 /\ live h q2 /\ live h table2 /\ eq_or_disjoint q1 q2 /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out scalar1 /\ disjoint out scalar2 /\ disjoint out table2 /\ as_nat h scalar1 < S.order /\ as_nat h scalar2 < S.order /\ point_inv h q1 /\ from_mont_point (as_point_nat h q1) == S.base_point /\ point_inv h q2 /\ table_inv_w5 (as_seq h q2) (as_seq h table2)) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ refl (as_seq h1 out) == S.to_aff_point (S.point_mul_double_g (as_nat h0 scalar1) (as_nat h0 scalar2) (from_mont_point (as_point_nat h0 q2)))) let point_mul_g_double_vartime_noalloc out scalar1 q1 scalar2 q2 table2 = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in [@inline_let] let bLen = 4ul in [@inline_let] let bBits = 256ul in assert_norm (pow2 (v l) == v table_len); let h0 = ST.get () in recall_contents precomp_basepoint_table_w5 precomp_basepoint_table_lseq_w5; let h1 = ST.get () in precomp_basepoint_table_lemma_w5 (); assert (table_inv_w5 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w5)); assert (table_inv_w5 (as_seq h1 q2) (as_seq h1 table2)); ME.mk_lexp_double_fw_tables len ctx_len k l table_len table_inv_w5 table_inv_w5 (BE.lprecomp_get_vartime len ctx_len k l table_len) (BE.lprecomp_get_vartime len ctx_len k l table_len) (null uint64) q1 bLen bBits scalar1 q2 scalar2 (to_const precomp_basepoint_table_w5) (to_const table2) out; SE.exp_double_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 q1)) 256 (as_nat h0 scalar1) (from_mont_point (as_point_nat h0 q2)) (as_nat h0 scalar2) 5 [@CInline]
false
false
Hacl.Impl.P256.PointMul.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 point_mul_double_g: res:point -> scalar1:felem -> scalar2:felem -> p:point -> Stack unit (requires fun h -> live h res /\ live h scalar1 /\ live h scalar2 /\ live h p /\ disjoint res scalar1 /\ disjoint res scalar2 /\ disjoint res p /\ disjoint p scalar1 /\ disjoint p scalar2 /\ point_inv h p /\ as_nat h scalar1 < S.order /\ as_nat h scalar2 < S.order) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ point_inv h1 res /\ S.to_aff_point (from_mont_point (as_point_nat h1 res)) == S.to_aff_point (S.point_mul_double_g (as_nat h0 scalar1) (as_nat h0 scalar2) (from_mont_point (as_point_nat h0 p))))
[]
Hacl.Impl.P256.PointMul.point_mul_double_g
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
res: Hacl.Impl.P256.Point.point -> scalar1: Hacl.Impl.P256.Bignum.felem -> scalar2: Hacl.Impl.P256.Bignum.felem -> p: Hacl.Impl.P256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 254, "start_col": 2, "start_line": 239 }
FStar.HyperStack.ST.Stack
val point_mul_g: res:point -> scalar:felem -> Stack unit (requires fun h -> live h res /\ live h scalar /\ disjoint res scalar /\ as_nat h scalar < S.order) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ point_inv h1 res /\ S.to_aff_point (from_mont_point (as_point_nat h1 res)) == S.to_aff_point (S.point_mul_g (as_nat h0 scalar)))
[ { "abbrev": false, "full_module": "Hacl.P256.PrecompTable", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Group", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256.Lemmas", "short_module": "SL" }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": true, "full_module": "Hacl.Spec.Bignum.Definitions", "short_module": "BD" }, { "abbrev": true, "full_module": "Hacl.Spec.PrecompBaseTable256", "short_module": "SPT256" }, { "abbrev": true, "full_module": "Hacl.Impl.PrecompTable", "short_module": "PT" }, { "abbrev": true, "full_module": "Hacl.Impl.MultiExponentiation", "short_module": "ME" }, { "abbrev": true, "full_module": "Hacl.Impl.Exponentiation", "short_module": "BE" }, { "abbrev": true, "full_module": "Spec.Exponentiation", "short_module": "SE" }, { "abbrev": true, "full_module": "Lib.Exponentiation", "short_module": "LE" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Field", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": true, "full_module": "Spec.P256", "short_module": "S" }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Point", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256.Bignum", "short_module": null }, { "abbrev": false, "full_module": "Lib.Buffer", "short_module": null }, { "abbrev": false, "full_module": "Lib.IntTypes", "short_module": null }, { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "ST" }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack.All", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.P256", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let point_mul_g res scalar = push_frame (); let h0 = ST.get () in let q1 = create_point () in make_base_point q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc res scalar q1 q2 q3 q4; LowStar.Ignore.ignore q1; LowStar.Ignore.ignore q2; LowStar.Ignore.ignore q3; LowStar.Ignore.ignore q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame ()
val point_mul_g: res:point -> scalar:felem -> Stack unit (requires fun h -> live h res /\ live h scalar /\ disjoint res scalar /\ as_nat h scalar < S.order) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ point_inv h1 res /\ S.to_aff_point (from_mont_point (as_point_nat h1 res)) == S.to_aff_point (S.point_mul_g (as_nat h0 scalar))) let point_mul_g res scalar =
true
null
false
push_frame (); let h0 = ST.get () in let q1 = create_point () in make_base_point q1; let q2 = mk_proj_g_pow2_64 () in let q3 = mk_proj_g_pow2_128 () in let q4 = mk_proj_g_pow2_192 () in proj_g_pow2_64_lseq_lemma (); proj_g_pow2_128_lseq_lemma (); proj_g_pow2_192_lseq_lemma (); point_mul_g_noalloc res scalar q1 q2 q3 q4; LowStar.Ignore.ignore q1; LowStar.Ignore.ignore q2; LowStar.Ignore.ignore q3; LowStar.Ignore.ignore q4; lemma_exp_four_fw_local (as_seq h0 scalar); pop_frame ()
{ "checked_file": "Hacl.Impl.P256.PointMul.fst.checked", "dependencies": [ "Spec.P256.Lemmas.fsti.checked", "Spec.P256.fst.checked", "Spec.Exponentiation.fsti.checked", "prims.fst.checked", "LowStar.Ignore.fsti.checked", "Lib.IntTypes.fsti.checked", "Lib.Exponentiation.fsti.checked", "Lib.Buffer.fsti.checked", "Hacl.Spec.PrecompBaseTable256.fsti.checked", "Hacl.Spec.Bignum.Definitions.fst.checked", "Hacl.P256.PrecompTable.fsti.checked", "Hacl.Impl.PrecompTable.fsti.checked", "Hacl.Impl.P256.Point.fsti.checked", "Hacl.Impl.P256.Group.fst.checked", "Hacl.Impl.P256.Field.fsti.checked", "Hacl.Impl.P256.Bignum.fsti.checked", "Hacl.Impl.MultiExponentiation.fsti.checked", "Hacl.Impl.Exponentiation.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.All.fst.checked", "FStar.HyperStack.fst.checked" ], "interface_file": true, "source_file": "Hacl.Impl.P256.PointMul.fst" }
[]
[ "Hacl.Impl.P256.Point.point", "Hacl.Impl.P256.Bignum.felem", "FStar.HyperStack.ST.pop_frame", "Prims.unit", "Hacl.Impl.P256.PointMul.lemma_exp_four_fw_local", "Lib.Buffer.as_seq", "Lib.Buffer.MUT", "Lib.IntTypes.uint64", "Lib.IntTypes.size", "LowStar.Ignore.ignore", "Lib.Buffer.lbuffer", "FStar.UInt32.__uint_to_t", "Hacl.Impl.P256.PointMul.point_mul_g_noalloc", "Hacl.P256.PrecompTable.proj_g_pow2_192_lseq_lemma", "Hacl.P256.PrecompTable.proj_g_pow2_128_lseq_lemma", "Hacl.P256.PrecompTable.proj_g_pow2_64_lseq_lemma", "Lib.Buffer.lbuffer_t", "Lib.IntTypes.int_t", "Lib.IntTypes.U64", "Lib.IntTypes.SEC", "FStar.UInt32.uint_to_t", "FStar.UInt32.t", "Hacl.P256.PrecompTable.mk_proj_g_pow2_192", "Hacl.P256.PrecompTable.mk_proj_g_pow2_128", "Hacl.P256.PrecompTable.mk_proj_g_pow2_64", "Hacl.Impl.P256.Point.make_base_point", "Hacl.Impl.P256.Point.create_point", "FStar.Monotonic.HyperStack.mem", "FStar.HyperStack.ST.get", "FStar.HyperStack.ST.push_frame" ]
[]
module Hacl.Impl.P256.PointMul open FStar.Mul open FStar.HyperStack.All open FStar.HyperStack module ST = FStar.HyperStack.ST open Lib.IntTypes open Lib.Buffer open Hacl.Impl.P256.Bignum open Hacl.Impl.P256.Field open Hacl.Impl.P256.Point module LE = Lib.Exponentiation module SE = Spec.Exponentiation module BE = Hacl.Impl.Exponentiation module ME = Hacl.Impl.MultiExponentiation module PT = Hacl.Impl.PrecompTable module SPT256 = Hacl.Spec.PrecompBaseTable256 module BD = Hacl.Spec.Bignum.Definitions module S = Spec.P256 module SL = Spec.P256.Lemmas include Hacl.Impl.P256.Group include Hacl.P256.PrecompTable #set-options "--z3rlimit 50 --fuel 0 --ifuel 0" inline_for_extraction noextract let table_inv_w4 : BE.table_inv_t U64 12ul 16ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.table_inv_precomp len ctx_len k l table_len inline_for_extraction noextract let table_inv_w5 : BE.table_inv_t U64 12ul 32ul = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 5ul in [@inline_let] let table_len = 32ul in assert_norm (pow2 (v l) == v table_len); BE.table_inv_precomp len ctx_len k l table_len [@CInline] let point_mul res scalar p = let h0 = ST.get () in SE.exp_fw_lemma S.mk_p256_concrete_ops (from_mont_point (as_point_nat h0 p)) 256 (as_nat h0 scalar) 4; BE.lexp_fw_consttime 12ul 0ul mk_p256_concrete_ops 4ul (null uint64) p 4ul 256ul scalar res val precomp_get_consttime: BE.pow_a_to_small_b_st U64 12ul 0ul mk_p256_concrete_ops 4ul 16ul (BE.table_inv_precomp 12ul 0ul mk_p256_concrete_ops 4ul 16ul) [@CInline] let precomp_get_consttime ctx a table bits_l tmp = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in BE.lprecomp_get_consttime len ctx_len k l table_len ctx a table bits_l tmp inline_for_extraction noextract val point_mul_g_noalloc: out:point -> scalar:felem -> q1:point -> q2:point -> q3:point -> q4:point -> Stack unit (requires fun h -> live h scalar /\ live h out /\ live h q1 /\ live h q2 /\ live h q3 /\ live h q4 /\ disjoint out scalar /\ disjoint out q1 /\ disjoint out q2 /\ disjoint out q3 /\ disjoint out q4 /\ disjoint q1 q2 /\ disjoint q1 q3 /\ disjoint q1 q4 /\ disjoint q2 q3 /\ disjoint q2 q4 /\ disjoint q3 q4 /\ as_nat h scalar < S.order /\ point_inv h q1 /\ refl (as_seq h q1) == g_aff /\ point_inv h q2 /\ refl (as_seq h q2) == g_pow2_64 /\ point_inv h q3 /\ refl (as_seq h q3) == g_pow2_128 /\ point_inv h q4 /\ refl (as_seq h q4) == g_pow2_192) (ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\ point_inv h1 out /\ (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (as_nat h0 scalar) in S.to_aff_point (from_mont_point (as_point_nat h1 out)) == LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4)) let point_mul_g_noalloc out scalar q1 q2 q3 q4 = [@inline_let] let len = 12ul in [@inline_let] let ctx_len = 0ul in [@inline_let] let k = mk_p256_concrete_ops in [@inline_let] let l = 4ul in [@inline_let] let table_len = 16ul in [@inline_let] let bLen = 1ul in [@inline_let] let bBits = 64ul in let h0 = ST.get () in recall_contents precomp_basepoint_table_w4 precomp_basepoint_table_lseq_w4; let h1 = ST.get () in precomp_basepoint_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q1) (as_seq h1 precomp_basepoint_table_w4)); recall_contents precomp_g_pow2_64_table_w4 precomp_g_pow2_64_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_64_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q2) (as_seq h1 precomp_g_pow2_64_table_w4)); recall_contents precomp_g_pow2_128_table_w4 precomp_g_pow2_128_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_128_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q3) (as_seq h1 precomp_g_pow2_128_table_w4)); recall_contents precomp_g_pow2_192_table_w4 precomp_g_pow2_192_table_lseq_w4; let h1 = ST.get () in precomp_g_pow2_192_table_lemma_w4 (); assert (table_inv_w4 (as_seq h1 q4) (as_seq h1 precomp_g_pow2_192_table_w4)); let r1 = sub scalar 0ul 1ul in let r2 = sub scalar 1ul 1ul in let r3 = sub scalar 2ul 1ul in let r4 = sub scalar 3ul 1ul in SPT256.lemma_decompose_nat256_as_four_u64_lbignum (as_seq h0 scalar); ME.mk_lexp_four_fw_tables len ctx_len k l table_len table_inv_w4 table_inv_w4 table_inv_w4 table_inv_w4 precomp_get_consttime precomp_get_consttime precomp_get_consttime precomp_get_consttime (null uint64) q1 bLen bBits r1 q2 r2 q3 r3 q4 r4 (to_const precomp_basepoint_table_w4) (to_const precomp_g_pow2_64_table_w4) (to_const precomp_g_pow2_128_table_w4) (to_const precomp_g_pow2_192_table_w4) out val lemma_exp_four_fw_local: b:BD.lbignum U64 4{BD.bn_v b < S.order} -> Lemma (let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in LE.exp_four_fw S.mk_p256_comm_monoid g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 == S.to_aff_point (S.point_mul_g (BD.bn_v b))) let lemma_exp_four_fw_local b = let cm = S.mk_p256_comm_monoid in let (b0, b1, b2, b3) = SPT256.decompose_nat256_as_four_u64 (BD.bn_v b) in let res = LE.exp_four_fw cm g_aff 64 b0 g_pow2_64 b1 g_pow2_128 b2 g_pow2_192 b3 4 in assert (res == SPT256.exp_as_exp_four_nat256_precomp cm g_aff (BD.bn_v b)); SPT256.lemma_point_mul_base_precomp4 cm g_aff (BD.bn_v b); assert (res == LE.pow cm g_aff (BD.bn_v b)); SE.exp_fw_lemma S.mk_p256_concrete_ops S.base_point 256 (BD.bn_v b) 4; LE.exp_fw_lemma cm g_aff 256 (BD.bn_v b) 4; assert (S.to_aff_point (S.point_mul_g (BD.bn_v b)) == LE.pow cm g_aff (BD.bn_v b)) [@CInline]
false
false
Hacl.Impl.P256.PointMul.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 point_mul_g: res:point -> scalar:felem -> Stack unit (requires fun h -> live h res /\ live h scalar /\ disjoint res scalar /\ as_nat h scalar < S.order) (ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\ point_inv h1 res /\ S.to_aff_point (from_mont_point (as_point_nat h1 res)) == S.to_aff_point (S.point_mul_g (as_nat h0 scalar)))
[]
Hacl.Impl.P256.PointMul.point_mul_g
{ "file_name": "code/ecdsap256/Hacl.Impl.P256.PointMul.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
res: Hacl.Impl.P256.Point.point -> scalar: Hacl.Impl.P256.Bignum.felem -> FStar.HyperStack.ST.Stack Prims.unit
{ "end_col": 14, "end_line": 181, "start_col": 2, "start_line": 165 }
Prims.Tot
val sel (#a #b: _) (m: map' a b) (x: a) : Tot (option (b x))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x
val sel (#a #b: _) (m: map' a b) (x: a) : Tot (option (b x)) let sel #a #b (m: map' a b) (x: a) : Tot (option (b x)) =
false
null
false
m x
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "total" ]
[ "FStar.Monotonic.Map.map'", "FStar.Pervasives.Native.option" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a)
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val sel (#a #b: _) (m: map' a b) (x: a) : Tot (option (b x))
[]
FStar.Monotonic.Map.sel
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Monotonic.Map.map' a b -> x: a -> FStar.Pervasives.Native.option (b x)
{ "end_col": 7, "end_line": 39, "start_col": 4, "start_line": 39 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let grows #a #b #inv = grows_aux #a #b #inv
let grows #a #b #inv =
false
null
false
grows_aux #a #b #inv
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "total" ]
[ "FStar.Monotonic.Map.map'", "FStar.Monotonic.Map.grows_aux", "FStar.Preorder.preorder", "FStar.Monotonic.Map.map" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x)
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val grows : FStar.Preorder.preorder (FStar.Monotonic.Map.map a b inv)
[]
FStar.Monotonic.Map.grows
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Preorder.preorder (FStar.Monotonic.Map.map a b inv)
{ "end_col": 43, "end_line": 47, "start_col": 23, "start_line": 47 }
Prims.GTot
val defined (#r #a #b #inv: _) (m: t r a b inv) (x: a) (h: HS.mem) : GTot Type0
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let defined #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x)
val defined (#r #a #b #inv: _) (m: t r a b inv) (x: a) (h: HS.mem) : GTot Type0 let defined #r #a #b #inv (m: t r a b inv) (x: a) (h: HS.mem) : GTot Type0 =
false
null
false
Some? (sel (HS.sel h m) x)
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "sometrivial" ]
[ "FStar.HyperStack.ST.erid", "FStar.Monotonic.Map.map'", "FStar.Monotonic.Map.t", "FStar.Monotonic.HyperStack.mem", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Monotonic.Map.sel", "FStar.Monotonic.HyperStack.sel", "FStar.Monotonic.Map.map", "FStar.Monotonic.Map.grows" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x) [@@"opaque_to_smt"] let grows #a #b #inv = grows_aux #a #b #inv (* Monotone, partial, dependent maps, with a whole-map invariant *) type t r a b inv = m_rref r (map a b inv) grows //maybe grows can include the inv? let empty_map a b : Tot (map' a b) = fun x -> None type rid = HST.erid let alloc (#r:rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) = ralloc r (empty_map a b) let defined #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem)
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val defined (#r #a #b #inv: _) (m: t r a b inv) (x: a) (h: HS.mem) : GTot Type0
[]
FStar.Monotonic.Map.defined
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Monotonic.Map.t r a b inv -> x: a -> h: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0
{ "end_col": 30, "end_line": 68, "start_col": 4, "start_line": 68 }
Prims.Tot
val empty_map (a b: _) : Tot (map' a b)
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_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_map a b : Tot (map' a b) = fun x -> None
val empty_map (a b: _) : Tot (map' a b) let empty_map a b : Tot (map' a b) =
false
null
false
fun x -> None
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "FStar.Monotonic.Map.map'" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x) [@@"opaque_to_smt"] let grows #a #b #inv = grows_aux #a #b #inv (* Monotone, partial, dependent maps, with a whole-map invariant *) type t r a b inv = m_rref r (map a b inv) grows //maybe grows can include the inv? let empty_map a b
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val empty_map (a b: _) : Tot (map' a b)
[]
FStar.Monotonic.Map.empty_map
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: Type -> b: (_: a -> Type) -> FStar.Monotonic.Map.map' a b
{ "end_col": 17, "end_line": 54, "start_col": 4, "start_line": 54 }
Prims.GTot
val fresh (#r #a #b #inv: _) (m: t r a b inv) (x: a) (h: HS.mem) : GTot Type0
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fresh #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = None? (sel (HS.sel h m) x)
val fresh (#r #a #b #inv: _) (m: t r a b inv) (x: a) (h: HS.mem) : GTot Type0 let fresh #r #a #b #inv (m: t r a b inv) (x: a) (h: HS.mem) : GTot Type0 =
false
null
false
None? (sel (HS.sel h m) x)
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "sometrivial" ]
[ "FStar.HyperStack.ST.erid", "FStar.Monotonic.Map.map'", "FStar.Monotonic.Map.t", "FStar.Monotonic.HyperStack.mem", "Prims.b2t", "FStar.Pervasives.Native.uu___is_None", "FStar.Monotonic.Map.sel", "FStar.Monotonic.HyperStack.sel", "FStar.Monotonic.Map.map", "FStar.Monotonic.Map.grows" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x) [@@"opaque_to_smt"] let grows #a #b #inv = grows_aux #a #b #inv (* Monotone, partial, dependent maps, with a whole-map invariant *) type t r a b inv = m_rref r (map a b inv) grows //maybe grows can include the inv? let empty_map a b : Tot (map' a b) = fun x -> None type rid = HST.erid let alloc (#r:rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) = ralloc r (empty_map a b) let defined #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) let contains #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) /\ Some?.v (sel (HS.sel h m) x) == y let value #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem{defined m x h}) : GTot (r:b x{contains m x r h}) = Some?.v (sel (HS.sel h m) x) let fresh #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem)
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fresh (#r #a #b #inv: _) (m: t r a b inv) (x: a) (h: HS.mem) : GTot Type0
[]
FStar.Monotonic.Map.fresh
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Monotonic.Map.t r a b inv -> x: a -> h: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0
{ "end_col": 30, "end_line": 80, "start_col": 4, "start_line": 80 }
Prims.GTot
val contains (#r #a #b #inv: _) (m: t r a b inv) (x: a) (y: b x) (h: HS.mem) : GTot Type0
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_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 #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) /\ Some?.v (sel (HS.sel h m) x) == y
val contains (#r #a #b #inv: _) (m: t r a b inv) (x: a) (y: b x) (h: HS.mem) : GTot Type0 let contains #r #a #b #inv (m: t r a b inv) (x: a) (y: b x) (h: HS.mem) : GTot Type0 =
false
null
false
Some? (sel (HS.sel h m) x) /\ Some?.v (sel (HS.sel h m) x) == y
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "sometrivial" ]
[ "FStar.HyperStack.ST.erid", "FStar.Monotonic.Map.map'", "FStar.Monotonic.Map.t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "FStar.Monotonic.Map.sel", "FStar.Monotonic.HyperStack.sel", "FStar.Monotonic.Map.map", "FStar.Monotonic.Map.grows", "Prims.eq2", "FStar.Pervasives.Native.__proj__Some__item__v" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x) [@@"opaque_to_smt"] let grows #a #b #inv = grows_aux #a #b #inv (* Monotone, partial, dependent maps, with a whole-map invariant *) type t r a b inv = m_rref r (map a b inv) grows //maybe grows can include the inv? let empty_map a b : Tot (map' a b) = fun x -> None type rid = HST.erid let alloc (#r:rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) = ralloc r (empty_map a b) let defined #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) let contains #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) (h:HS.mem)
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val contains (#r #a #b #inv: _) (m: t r a b inv) (x: a) (y: b x) (h: HS.mem) : GTot Type0
[]
FStar.Monotonic.Map.contains
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Monotonic.Map.t r a b inv -> x: a -> y: b x -> h: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0
{ "end_col": 67, "end_line": 72, "start_col": 4, "start_line": 72 }
Prims.Tot
val upd (#a: eqtype) (#b: _) (m: map' a b) (x: a) (y: b x) : Tot (map' a b)
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_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 (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z
val upd (#a: eqtype) (#b: _) (m: map' a b) (x: a) (y: b x) : Tot (map' a b) let upd (#a: eqtype) #b (m: map' a b) (x: a) (y: b x) : Tot (map' a b) =
false
null
false
fun z -> if x = z then Some y else m z
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "total" ]
[ "Prims.eqtype", "FStar.Monotonic.Map.map'", "Prims.op_Equality", "FStar.Pervasives.Native.Some", "Prims.bool", "FStar.Pervasives.Native.option" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x)
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val upd (#a: eqtype) (#b: _) (m: map' a b) (x: a) (y: b x) : Tot (map' a b)
[]
FStar.Monotonic.Map.upd
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Monotonic.Map.map' a b -> x: a -> y: b x -> FStar.Monotonic.Map.map' a b
{ "end_col": 42, "end_line": 35, "start_col": 4, "start_line": 35 }
Prims.GTot
val value (#r #a #b #inv: _) (m: t r a b inv) (x: a) (h: HS.mem{defined m x h}) : GTot (r: b x {contains m x r h})
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let value #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem{defined m x h}) : GTot (r:b x{contains m x r h}) = Some?.v (sel (HS.sel h m) x)
val value (#r #a #b #inv: _) (m: t r a b inv) (x: a) (h: HS.mem{defined m x h}) : GTot (r: b x {contains m x r h}) let value #r #a #b #inv (m: t r a b inv) (x: a) (h: HS.mem{defined m x h}) : GTot (r: b x {contains m x r h}) =
false
null
false
Some?.v (sel (HS.sel h m) x)
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "sometrivial" ]
[ "FStar.HyperStack.ST.erid", "FStar.Monotonic.Map.map'", "FStar.Monotonic.Map.t", "FStar.Monotonic.HyperStack.mem", "FStar.Monotonic.Map.defined", "FStar.Pervasives.Native.__proj__Some__item__v", "FStar.Monotonic.Map.sel", "FStar.Monotonic.HyperStack.sel", "FStar.Monotonic.Map.map", "FStar.Monotonic.Map.grows", "FStar.Monotonic.Map.contains" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x) [@@"opaque_to_smt"] let grows #a #b #inv = grows_aux #a #b #inv (* Monotone, partial, dependent maps, with a whole-map invariant *) type t r a b inv = m_rref r (map a b inv) grows //maybe grows can include the inv? let empty_map a b : Tot (map' a b) = fun x -> None type rid = HST.erid let alloc (#r:rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) = ralloc r (empty_map a b) let defined #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) let contains #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) /\ Some?.v (sel (HS.sel h m) x) == y let value #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem{defined m x h})
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val value (#r #a #b #inv: _) (m: t r a b inv) (x: a) (h: HS.mem{defined m x h}) : GTot (r: b x {contains m x r h})
[]
FStar.Monotonic.Map.value
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Monotonic.Map.t r a b inv -> x: a -> h: FStar.Monotonic.HyperStack.mem{FStar.Monotonic.Map.defined m x h} -> Prims.GTot (r: b x {FStar.Monotonic.Map.contains m x r h})
{ "end_col": 32, "end_line": 76, "start_col": 4, "start_line": 76 }
Prims.Tot
val grows_aux (#a #b #inv: _) : Preorder.preorder (map a b inv)
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x)
val grows_aux (#a #b #inv: _) : Preorder.preorder (map a b inv) let grows_aux #a #b #inv : Preorder.preorder (map a b inv) =
false
null
false
fun (m1: map a b inv) (m2: map a b inv) -> forall x. {:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x)
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "total" ]
[ "FStar.Monotonic.Map.map'", "FStar.Monotonic.Map.map", "Prims.l_Forall", "Prims.l_imp", "Prims.b2t", "FStar.Pervasives.Native.uu___is_Some", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.__proj__Some__item__v", "Prims.logical", "FStar.Preorder.preorder" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val grows_aux (#a #b #inv: _) : Preorder.preorder (map a b inv)
[]
FStar.Monotonic.Map.grows_aux
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.Preorder.preorder (FStar.Monotonic.Map.map a b inv)
{ "end_col": 71, "end_line": 44, "start_col": 2, "start_line": 42 }
FStar.Pervasives.Lemma
val contains_stable (#r #a #b #inv: _) (m: t r a b inv) (x: a) (y: b x) : Lemma (ensures (stable_on_t m (contains m x y)))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_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_stable #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) : Lemma (ensures (stable_on_t m (contains m x y))) = reveal_opaque (`%grows) (grows #a #b #inv)
val contains_stable (#r #a #b #inv: _) (m: t r a b inv) (x: a) (y: b x) : Lemma (ensures (stable_on_t m (contains m x y))) let contains_stable #r #a #b #inv (m: t r a b inv) (x: a) (y: b x) : Lemma (ensures (stable_on_t m (contains m x y))) =
false
null
true
reveal_opaque (`%grows) (grows #a #b #inv)
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[ "lemma" ]
[ "FStar.HyperStack.ST.erid", "FStar.Monotonic.Map.map'", "FStar.Monotonic.Map.t", "FStar.Pervasives.reveal_opaque", "FStar.Preorder.preorder", "FStar.Monotonic.Map.map", "FStar.Monotonic.Map.grows", "Prims.unit", "Prims.l_True", "Prims.squash", "FStar.HyperStack.ST.stable_on_t", "FStar.Monotonic.Map.contains", "Prims.Nil", "FStar.Pervasives.pattern" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x) [@@"opaque_to_smt"] let grows #a #b #inv = grows_aux #a #b #inv (* Monotone, partial, dependent maps, with a whole-map invariant *) type t r a b inv = m_rref r (map a b inv) grows //maybe grows can include the inv? let empty_map a b : Tot (map' a b) = fun x -> None type rid = HST.erid let alloc (#r:rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) = ralloc r (empty_map a b) let defined #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) let contains #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) /\ Some?.v (sel (HS.sel h m) x) == y let value #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem{defined m x h}) : GTot (r:b x{contains m x r h}) = Some?.v (sel (HS.sel h m) x) let fresh #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = None? (sel (HS.sel h m) x) let contains_stable #r #a #b #inv (m:t r a b inv) (x:a) (y:b x)
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val contains_stable (#r #a #b #inv: _) (m: t r a b inv) (x: a) (y: b x) : Lemma (ensures (stable_on_t m (contains m x y)))
[]
FStar.Monotonic.Map.contains_stable
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Monotonic.Map.t r a b inv -> x: a -> y: b x -> FStar.Pervasives.Lemma (ensures FStar.HyperStack.ST.stable_on_t m (FStar.Monotonic.Map.contains m x y))
{ "end_col": 46, "end_line": 84, "start_col": 4, "start_line": 84 }
FStar.HyperStack.ST.ST
val alloc (#r: rid) (#a #b #inv: _) : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_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 (#r:rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) = ralloc r (empty_map a b)
val alloc (#r: rid) (#a #b #inv: _) : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) let alloc (#r: rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) =
true
null
false
ralloc r (empty_map a b)
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[]
[ "FStar.Monotonic.Map.rid", "FStar.Monotonic.Map.map'", "FStar.HyperStack.ST.ralloc", "FStar.Monotonic.Map.map", "FStar.Monotonic.Map.grows", "FStar.Monotonic.Map.empty_map", "FStar.HyperStack.ST.mref", "FStar.Monotonic.Map.t", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "FStar.HyperStack.ST.witnessed", "FStar.HyperStack.ST.region_contains_pred", "FStar.HyperStack.ST.ralloc_post" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x) [@@"opaque_to_smt"] let grows #a #b #inv = grows_aux #a #b #inv (* Monotone, partial, dependent maps, with a whole-map invariant *) type t r a b inv = m_rref r (map a b inv) grows //maybe grows can include the inv? let empty_map a b : Tot (map' a b) = fun x -> None type rid = HST.erid let alloc (#r:rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val alloc (#r: rid) (#a #b #inv: _) : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1))
[]
FStar.Monotonic.Map.alloc
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
FStar.HyperStack.ST.ST (FStar.Monotonic.Map.t r a b inv)
{ "end_col": 28, "end_line": 64, "start_col": 4, "start_line": 64 }
FStar.HyperStack.ST.ST
val lookup (#r #a #b #inv: _) (m: t r a b inv) (x: a) : ST (option (b x)) (requires (fun h -> True)) (ensures (fun h0 y h1 -> h0 == h1 /\ y == sel (HS.sel h1 m) x /\ (None? y ==> fresh m x h1) /\ (Some? y ==> defined m x h1 /\ contains m x (Some?.v y) h1 /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x (Some?.v y)))))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lookup #r #a #b #inv (m:t r a b inv) (x:a) : ST (option (b x)) (requires (fun h -> True)) (ensures (fun h0 y h1 -> h0==h1 /\ y == sel (HS.sel h1 m) x /\ (None? y ==> fresh m x h1) /\ (Some? y ==> defined m x h1 /\ contains m x (Some?.v y) h1 /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x (Some?.v y))))) = reveal_opaque (`%grows) (grows #a #b #inv); let y = sel !m x in match y with | None -> y | Some b -> contains_stable m x b; mr_witness m (defined m x); mr_witness m (contains m x b); y
val lookup (#r #a #b #inv: _) (m: t r a b inv) (x: a) : ST (option (b x)) (requires (fun h -> True)) (ensures (fun h0 y h1 -> h0 == h1 /\ y == sel (HS.sel h1 m) x /\ (None? y ==> fresh m x h1) /\ (Some? y ==> defined m x h1 /\ contains m x (Some?.v y) h1 /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x (Some?.v y))))) let lookup #r #a #b #inv (m: t r a b inv) (x: a) : ST (option (b x)) (requires (fun h -> True)) (ensures (fun h0 y h1 -> h0 == h1 /\ y == sel (HS.sel h1 m) x /\ (None? y ==> fresh m x h1) /\ (Some? y ==> defined m x h1 /\ contains m x (Some?.v y) h1 /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x (Some?.v y))))) =
true
null
false
reveal_opaque (`%grows) (grows #a #b #inv); let y = sel !m x in match y with | None -> y | Some b -> contains_stable m x b; mr_witness m (defined m x); mr_witness m (contains m x b); y
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[]
[ "FStar.HyperStack.ST.erid", "FStar.Monotonic.Map.map'", "FStar.Monotonic.Map.t", "FStar.Pervasives.Native.option", "Prims.unit", "FStar.HyperStack.ST.mr_witness", "FStar.Monotonic.Map.map", "FStar.Monotonic.Map.grows", "FStar.Monotonic.Map.contains", "FStar.Monotonic.Map.defined", "FStar.Monotonic.Map.contains_stable", "FStar.Monotonic.Map.sel", "FStar.HyperStack.ST.op_Bang", "FStar.Pervasives.reveal_opaque", "FStar.Preorder.preorder", "FStar.Monotonic.HyperStack.mem", "Prims.l_True", "Prims.l_and", "Prims.eq2", "FStar.Monotonic.HyperStack.sel", "Prims.l_imp", "Prims.b2t", "FStar.Pervasives.Native.uu___is_None", "FStar.Monotonic.Map.fresh", "FStar.Pervasives.Native.uu___is_Some", "FStar.Pervasives.Native.__proj__Some__item__v", "FStar.HyperStack.ST.witnessed" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x) [@@"opaque_to_smt"] let grows #a #b #inv = grows_aux #a #b #inv (* Monotone, partial, dependent maps, with a whole-map invariant *) type t r a b inv = m_rref r (map a b inv) grows //maybe grows can include the inv? let empty_map a b : Tot (map' a b) = fun x -> None type rid = HST.erid let alloc (#r:rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) = ralloc r (empty_map a b) let defined #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) let contains #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) /\ Some?.v (sel (HS.sel h m) x) == y let value #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem{defined m x h}) : GTot (r:b x{contains m x r h}) = Some?.v (sel (HS.sel h m) x) let fresh #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = None? (sel (HS.sel h m) x) let contains_stable #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) : Lemma (ensures (stable_on_t m (contains m x y))) = reveal_opaque (`%grows) (grows #a #b #inv) let extend (#r:rid) (#a:eqtype) (#b:a -> Type) (#inv:(map' a b -> Type0)) (m:t r a b inv) (x:a) (y:b x) : ST unit (requires (fun h -> let cur = HS.sel h m in inv (upd cur x y) /\ sel cur x == None)) (ensures (fun h0 u h1 -> let cur = HS.sel h0 m in let hsref = m in HS.contains h1 m /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r (Set.singleton (HS.as_addr hsref)) h0 h1 /\ HS.sel h1 m == upd cur x y /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x y))) = recall m; reveal_opaque (`%grows) (grows #a #b #inv); let cur = !m in m := upd cur x y; contains_stable m x y; mr_witness m (defined m x); mr_witness m (contains m x y) let lookup #r #a #b #inv (m:t r a b inv) (x:a) : ST (option (b x)) (requires (fun h -> True)) (ensures (fun h0 y h1 -> h0==h1 /\ y == sel (HS.sel h1 m) x /\ (None? y ==> fresh m x h1) /\ (Some? y ==> defined m x h1 /\ contains m x (Some?.v y) h1 /\ HST.witnessed (defined m x) /\
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lookup (#r #a #b #inv: _) (m: t r a b inv) (x: a) : ST (option (b x)) (requires (fun h -> True)) (ensures (fun h0 y h1 -> h0 == h1 /\ y == sel (HS.sel h1 m) x /\ (None? y ==> fresh m x h1) /\ (Some? y ==> defined m x h1 /\ contains m x (Some?.v y) h1 /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x (Some?.v y)))))
[]
FStar.Monotonic.Map.lookup
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Monotonic.Map.t r a b inv -> x: a -> FStar.HyperStack.ST.ST (FStar.Pervasives.Native.option (b x))
{ "end_col": 9, "end_line": 126, "start_col": 2, "start_line": 118 }
FStar.HyperStack.ST.ST
val extend (#r: rid) (#a: eqtype) (#b: (a -> Type)) (#inv: (map' a b -> Type0)) (m: t r a b inv) (x: a) (y: b x) : ST unit (requires (fun h -> let cur = HS.sel h m in inv (upd cur x y) /\ sel cur x == None)) (ensures (fun h0 u h1 -> let cur = HS.sel h0 m in let hsref = m in HS.contains h1 m /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r (Set.singleton (HS.as_addr hsref)) h0 h1 /\ HS.sel h1 m == upd cur x y /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x y)))
[ { "abbrev": true, "full_module": "FStar.HyperStack.ST", "short_module": "HST" }, { "abbrev": true, "full_module": "FStar.HyperStack", "short_module": "HS" }, { "abbrev": false, "full_module": "FStar.HyperStack.ST", "short_module": null }, { "abbrev": false, "full_module": "FStar.HyperStack", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Monotonic", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let extend (#r:rid) (#a:eqtype) (#b:a -> Type) (#inv:(map' a b -> Type0)) (m:t r a b inv) (x:a) (y:b x) : ST unit (requires (fun h -> let cur = HS.sel h m in inv (upd cur x y) /\ sel cur x == None)) (ensures (fun h0 u h1 -> let cur = HS.sel h0 m in let hsref = m in HS.contains h1 m /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r (Set.singleton (HS.as_addr hsref)) h0 h1 /\ HS.sel h1 m == upd cur x y /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x y))) = recall m; reveal_opaque (`%grows) (grows #a #b #inv); let cur = !m in m := upd cur x y; contains_stable m x y; mr_witness m (defined m x); mr_witness m (contains m x y)
val extend (#r: rid) (#a: eqtype) (#b: (a -> Type)) (#inv: (map' a b -> Type0)) (m: t r a b inv) (x: a) (y: b x) : ST unit (requires (fun h -> let cur = HS.sel h m in inv (upd cur x y) /\ sel cur x == None)) (ensures (fun h0 u h1 -> let cur = HS.sel h0 m in let hsref = m in HS.contains h1 m /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r (Set.singleton (HS.as_addr hsref)) h0 h1 /\ HS.sel h1 m == upd cur x y /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x y))) let extend (#r: rid) (#a: eqtype) (#b: (a -> Type)) (#inv: (map' a b -> Type0)) (m: t r a b inv) (x: a) (y: b x) : ST unit (requires (fun h -> let cur = HS.sel h m in inv (upd cur x y) /\ sel cur x == None)) (ensures (fun h0 u h1 -> let cur = HS.sel h0 m in let hsref = m in HS.contains h1 m /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r (Set.singleton (HS.as_addr hsref)) h0 h1 /\ HS.sel h1 m == upd cur x y /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x y))) =
true
null
false
recall m; reveal_opaque (`%grows) (grows #a #b #inv); let cur = !m in m := upd cur x y; contains_stable m x y; mr_witness m (defined m x); mr_witness m (contains m x y)
{ "checked_file": "FStar.Monotonic.Map.fst.checked", "dependencies": [ "prims.fst.checked", "FStar.Set.fsti.checked", "FStar.Preorder.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.HyperStack.ST.fsti.checked", "FStar.HyperStack.fst.checked" ], "interface_file": false, "source_file": "FStar.Monotonic.Map.fst" }
[]
[ "FStar.Monotonic.Map.rid", "Prims.eqtype", "FStar.Monotonic.Map.map'", "FStar.Monotonic.Map.t", "FStar.HyperStack.ST.mr_witness", "FStar.Monotonic.Map.map", "FStar.Monotonic.Map.grows", "FStar.Monotonic.Map.contains", "Prims.unit", "FStar.Monotonic.Map.defined", "FStar.Monotonic.Map.contains_stable", "FStar.HyperStack.ST.op_Colon_Equals", "FStar.Monotonic.Map.upd", "FStar.HyperStack.ST.op_Bang", "FStar.Pervasives.reveal_opaque", "FStar.Preorder.preorder", "FStar.HyperStack.ST.recall", "FStar.Monotonic.HyperStack.mem", "Prims.l_and", "Prims.eq2", "FStar.Pervasives.Native.option", "FStar.Monotonic.Map.sel", "FStar.Pervasives.Native.None", "FStar.Monotonic.HyperStack.sel", "FStar.Monotonic.HyperStack.contains", "FStar.Monotonic.HyperStack.modifies", "FStar.Set.singleton", "FStar.Monotonic.HyperHeap.rid", "FStar.Monotonic.HyperStack.modifies_ref", "Prims.nat", "FStar.Monotonic.HyperStack.as_addr", "FStar.HyperStack.ST.witnessed" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) (** A library for monotonic references to partial, dependent maps, with a whole-map invariant *) module FStar.Monotonic.Map open FStar.HyperStack open FStar.HyperStack.ST module HS = FStar.HyperStack module HST = FStar.HyperStack.ST (* Partial, dependent maps *) type map' (a:Type) (b:a -> Type) = (x:a -> Tot (option (b x))) (* Partial, dependent maps, with a whole-map invariant *) type map (a:Type) (b:a -> Type) (inv:map' a b -> Type0) = m:map' a b{inv m} let upd (#a:eqtype) #b (m:map' a b) (x:a) (y:b x) : Tot (map' a b) = fun z -> if x = z then Some y else m z let sel #a #b (m:map' a b) (x:a) : Tot (option (b x)) = m x let grows_aux #a #b #inv :Preorder.preorder (map a b inv) = fun (m1 m2:map a b inv) -> forall x.{:pattern (Some? (m1 x))} Some? (m1 x) ==> Some? (m2 x) /\ Some?.v (m1 x) == Some?.v (m2 x) [@@"opaque_to_smt"] let grows #a #b #inv = grows_aux #a #b #inv (* Monotone, partial, dependent maps, with a whole-map invariant *) type t r a b inv = m_rref r (map a b inv) grows //maybe grows can include the inv? let empty_map a b : Tot (map' a b) = fun x -> None type rid = HST.erid let alloc (#r:rid) #a #b #inv : ST (t r a b inv) (requires (fun h -> inv (empty_map a b) /\ witnessed (region_contains_pred r))) (ensures (fun h0 x h1 -> inv (empty_map a b) /\ ralloc_post r (empty_map a b) h0 x h1)) = ralloc r (empty_map a b) let defined #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) let contains #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) (h:HS.mem) : GTot Type0 = Some? (sel (HS.sel h m) x) /\ Some?.v (sel (HS.sel h m) x) == y let value #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem{defined m x h}) : GTot (r:b x{contains m x r h}) = Some?.v (sel (HS.sel h m) x) let fresh #r #a #b #inv (m:t r a b inv) (x:a) (h:HS.mem) : GTot Type0 = None? (sel (HS.sel h m) x) let contains_stable #r #a #b #inv (m:t r a b inv) (x:a) (y:b x) : Lemma (ensures (stable_on_t m (contains m x y))) = reveal_opaque (`%grows) (grows #a #b #inv) let extend (#r:rid) (#a:eqtype) (#b:a -> Type) (#inv:(map' a b -> Type0)) (m:t r a b inv) (x:a) (y:b x) : ST unit (requires (fun h -> let cur = HS.sel h m in inv (upd cur x y) /\ sel cur x == None)) (ensures (fun h0 u h1 -> let cur = HS.sel h0 m in let hsref = m in HS.contains h1 m /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r (Set.singleton (HS.as_addr hsref)) h0 h1 /\ HS.sel h1 m == upd cur x y /\ HST.witnessed (defined m x)
false
false
FStar.Monotonic.Map.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val extend (#r: rid) (#a: eqtype) (#b: (a -> Type)) (#inv: (map' a b -> Type0)) (m: t r a b inv) (x: a) (y: b x) : ST unit (requires (fun h -> let cur = HS.sel h m in inv (upd cur x y) /\ sel cur x == None)) (ensures (fun h0 u h1 -> let cur = HS.sel h0 m in let hsref = m in HS.contains h1 m /\ modifies (Set.singleton r) h0 h1 /\ modifies_ref r (Set.singleton (HS.as_addr hsref)) h0 h1 /\ HS.sel h1 m == upd cur x y /\ HST.witnessed (defined m x) /\ HST.witnessed (contains m x y)))
[]
FStar.Monotonic.Map.extend
{ "file_name": "ulib/FStar.Monotonic.Map.fst", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: FStar.Monotonic.Map.t r a b inv -> x: a -> y: b x -> FStar.HyperStack.ST.ST Prims.unit
{ "end_col": 33, "end_line": 104, "start_col": 4, "start_line": 98 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fin (n: nat) = k: int {0 <= k /\ k < n}
let fin (n: nat) =
false
null
false
k: int{0 <= k /\ k < n}
{ "checked_file": "FStar.Fin.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.Fin.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.int", "Prims.l_and", "Prims.b2t", "Prims.op_LessThanOrEqual", "Prims.op_LessThan" ]
[]
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Fin /// This module is supposed to contain various lemmas about /// finiteness. For now, it mainly provides a basic pigeonhole /// principle /// /// TODO: We might generalize this to also support general utilities /// for reasoning about cardinality, relation with injections and /// surjections, etc. /// /// UPD. November 8, 2022 -- added support for custom equivalence relation-aware /// pigeon principle lemma. /// UPD. November 23, 2022 -- added interface file module L = FStar.List.Tot module S = FStar.Seq (** The type of natural numbers bounded by [n] *)
false
true
FStar.Fin.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 fin : n: Prims.nat -> Type0
[]
FStar.Fin.fin
{ "file_name": "ulib/FStar.Fin.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> Type0
{ "end_col": 43, "end_line": 36, "start_col": 19, "start_line": 36 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let in_ (#a: Type) (s: S.seq a) = n: nat{n < S.length s}
let in_ (#a: Type) (s: S.seq a) =
false
null
false
n: nat{n < S.length s}
{ "checked_file": "FStar.Fin.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.Fin.fsti" }
[ "total" ]
[ "FStar.Seq.Base.seq", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.length" ]
[]
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Fin /// This module is supposed to contain various lemmas about /// finiteness. For now, it mainly provides a basic pigeonhole /// principle /// /// TODO: We might generalize this to also support general utilities /// for reasoning about cardinality, relation with injections and /// surjections, etc. /// /// UPD. November 8, 2022 -- added support for custom equivalence relation-aware /// pigeon principle lemma. /// UPD. November 23, 2022 -- added interface file module L = FStar.List.Tot module S = FStar.Seq (** The type of natural numbers bounded by [n] *) inline_for_extraction let fin (n: nat) = k: int {0 <= k /\ k < n} (** Newer synonym. We perhaps should choose one over another globally. [under] is also defined in IntegerIntervals.fst, along with other often used finite intervals. *) inline_for_extraction let under (p:nat) = x:nat {x<p} (** Length-indexed list *) inline_for_extraction let vect (n: nat) (a: Type) = l: list a {L.length l = n} (** Length-indexed sequence *) inline_for_extraction let seqn (n: nat) (a: Type) = s: S.seq a {S.length s = n} (** [in_ s] is the type of a valid index into the sequence [s] *)
false
false
FStar.Fin.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 in_ : s: FStar.Seq.Base.seq a -> Type0
[]
FStar.Fin.in_
{ "file_name": "ulib/FStar.Fin.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
s: FStar.Seq.Base.seq a -> Type0
{ "end_col": 56, "end_line": 54, "start_col": 34, "start_line": 54 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let under (p:nat) = x:nat {x<p}
let under (p: nat) =
false
null
false
x: nat{x < p}
{ "checked_file": "FStar.Fin.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.Fin.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.b2t", "Prims.op_LessThan" ]
[]
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Fin /// This module is supposed to contain various lemmas about /// finiteness. For now, it mainly provides a basic pigeonhole /// principle /// /// TODO: We might generalize this to also support general utilities /// for reasoning about cardinality, relation with injections and /// surjections, etc. /// /// UPD. November 8, 2022 -- added support for custom equivalence relation-aware /// pigeon principle lemma. /// UPD. November 23, 2022 -- added interface file module L = FStar.List.Tot module S = FStar.Seq (** The type of natural numbers bounded by [n] *) inline_for_extraction let fin (n: nat) = k: int {0 <= k /\ k < n} (** Newer synonym. We perhaps should choose one over another globally. [under] is also defined in IntegerIntervals.fst, along with other often used finite intervals. *)
false
true
FStar.Fin.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 under : p: Prims.nat -> Type0
[]
FStar.Fin.under
{ "file_name": "ulib/FStar.Fin.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: Prims.nat -> Type0
{ "end_col": 31, "end_line": 42, "start_col": 20, "start_line": 42 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let items_of #a (eq: equivalence_relation a) (s: S.seq a) = x:a { contains_eq eq s x }
let items_of #a (eq: equivalence_relation a) (s: S.seq a) =
false
null
false
x: a{contains_eq eq s x}
{ "checked_file": "FStar.Fin.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.Fin.fsti" }
[ "total" ]
[ "FStar.Fin.equivalence_relation", "FStar.Seq.Base.seq", "FStar.Fin.contains_eq" ]
[]
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Fin /// This module is supposed to contain various lemmas about /// finiteness. For now, it mainly provides a basic pigeonhole /// principle /// /// TODO: We might generalize this to also support general utilities /// for reasoning about cardinality, relation with injections and /// surjections, etc. /// /// UPD. November 8, 2022 -- added support for custom equivalence relation-aware /// pigeon principle lemma. /// UPD. November 23, 2022 -- added interface file module L = FStar.List.Tot module S = FStar.Seq (** The type of natural numbers bounded by [n] *) inline_for_extraction let fin (n: nat) = k: int {0 <= k /\ k < n} (** Newer synonym. We perhaps should choose one over another globally. [under] is also defined in IntegerIntervals.fst, along with other often used finite intervals. *) inline_for_extraction let under (p:nat) = x:nat {x<p} (** Length-indexed list *) inline_for_extraction let vect (n: nat) (a: Type) = l: list a {L.length l = n} (** Length-indexed sequence *) inline_for_extraction let seqn (n: nat) (a: Type) = s: S.seq a {S.length s = n} (** [in_ s] is the type of a valid index into the sequence [s] *) inline_for_extraction let in_ (#a: Type) (s: S.seq a) = n: nat{n < S.length s} (** Find an index of an element in [s] starting from [i] that validates [p] *) val find (#a: Type) (s: S.seq a) (p: (a -> bool)) (i: under (S.length s)) : Pure (option (in_ s)) (requires True) (ensures (function | None -> (forall (k: nat{i <= k /\ k < S.length s}). p (S.index s k) == false) | Some j -> i <= j /\ p (S.index s j))) (decreases (S.length s - i)) (** Given a sequence [s] all of whose elements are at most [n], if the length of [s] is greater than [n], then there are two distinct indexes in [s] that contain the same element *) val pigeonhole (#n: pos) (s: S.seq (under n)) : Pure (in_ s * in_ s) (requires S.length s = n + 1) (ensures (fun (i1, i2) -> i1 < i2 /\ S.index s i1 = S.index s i2)) (decreases n) (** Here we prepare to prove pigeonhole principle for a finite sequence with a custom equivalence relation (as opposed to eqtype). Think setoids. *) (** Following code is extracted from CuteCAS, which will eventually make its way into F* -- when I wrap things up with most important notions of abstract algebra. As I port more code from my CAS project to F*, such things will be moved to separate modules. -- Alex Rozanov *) inline_for_extraction type binary_relation (a: Type) = a -> a -> bool (** For performance reasons, forall definitions are best kept hidden from SMT. Use reveal_opaque when you really need it. Or use refl/trans/symm lemmas below to keep the context clean. *) val is_reflexive (#a:Type) (r: binary_relation a) : Type0 val is_symmetric (#a:Type) (r: binary_relation a) : Type0 val is_transitive (#a:Type) (r: binary_relation a) : Type0 val is_reflexive_intro (#a:Type) (r: binary_relation a) : Lemma (requires forall (x:a). r x x) (ensures is_reflexive r) val is_symmetric_intro (#a:Type) (r: binary_relation a) : Lemma (requires forall (x:a). r x x) (ensures is_reflexive r) val is_transitive_intro (#a:Type) (r: binary_relation a) : Lemma (requires forall (x:a). r x x) (ensures is_reflexive r) (** Textbook stuff on equivalence relations *) type equivalence_relation (a: Type) = r:binary_relation a { is_reflexive r /\ is_symmetric r /\ is_transitive r } val refl_lemma (#a:Type) (eq: equivalence_relation a) (x:a) : Lemma (eq x x) val symm_lemma (#a:Type) (eq:equivalence_relation a) (x y:a) : Lemma (eq x y == eq y x) val trans_lemma (#a:Type) (eq: equivalence_relation a) (x y z:a) : Lemma (requires (eq x y \/ eq y x) /\ (eq y z \/ eq z y)) (ensures (x `eq` z) && (z `eq` x)) (** (contains) predicate, but with custom comparison operation (a->a->bool) *) [@@"opaque_to_smt"] let contains_eq #a (eq: equivalence_relation a) (s: S.seq a) (x:a) = exists (i:under (S.length s)). eq x (S.index s i) val contains_eq_means_nonempty (#a:Type) (eq:equivalence_relation a) (s: S.seq a) (x:a) : Lemma (requires contains_eq eq s x) (ensures S.length s > 0) [SMTPat(contains_eq eq s x)] (** a type of all elements present in a given sequence *)
false
false
FStar.Fin.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 items_of : eq: FStar.Fin.equivalence_relation a -> s: FStar.Seq.Base.seq a -> Type
[]
FStar.Fin.items_of
{ "file_name": "ulib/FStar.Fin.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
eq: FStar.Fin.equivalence_relation a -> s: FStar.Seq.Base.seq a -> Type
{ "end_col": 30, "end_line": 133, "start_col": 4, "start_line": 133 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let contains_eq #a (eq: equivalence_relation a) (s: S.seq a) (x:a) = exists (i:under (S.length s)). eq x (S.index s i)
let contains_eq #a (eq: equivalence_relation a) (s: S.seq a) (x: a) =
false
null
false
exists (i: under (S.length s)). eq x (S.index s i)
{ "checked_file": "FStar.Fin.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.Fin.fsti" }
[ "total" ]
[ "FStar.Fin.equivalence_relation", "FStar.Seq.Base.seq", "Prims.l_Exists", "FStar.Fin.under", "FStar.Seq.Base.length", "Prims.b2t", "FStar.Seq.Base.index", "Prims.logical" ]
[]
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Fin /// This module is supposed to contain various lemmas about /// finiteness. For now, it mainly provides a basic pigeonhole /// principle /// /// TODO: We might generalize this to also support general utilities /// for reasoning about cardinality, relation with injections and /// surjections, etc. /// /// UPD. November 8, 2022 -- added support for custom equivalence relation-aware /// pigeon principle lemma. /// UPD. November 23, 2022 -- added interface file module L = FStar.List.Tot module S = FStar.Seq (** The type of natural numbers bounded by [n] *) inline_for_extraction let fin (n: nat) = k: int {0 <= k /\ k < n} (** Newer synonym. We perhaps should choose one over another globally. [under] is also defined in IntegerIntervals.fst, along with other often used finite intervals. *) inline_for_extraction let under (p:nat) = x:nat {x<p} (** Length-indexed list *) inline_for_extraction let vect (n: nat) (a: Type) = l: list a {L.length l = n} (** Length-indexed sequence *) inline_for_extraction let seqn (n: nat) (a: Type) = s: S.seq a {S.length s = n} (** [in_ s] is the type of a valid index into the sequence [s] *) inline_for_extraction let in_ (#a: Type) (s: S.seq a) = n: nat{n < S.length s} (** Find an index of an element in [s] starting from [i] that validates [p] *) val find (#a: Type) (s: S.seq a) (p: (a -> bool)) (i: under (S.length s)) : Pure (option (in_ s)) (requires True) (ensures (function | None -> (forall (k: nat{i <= k /\ k < S.length s}). p (S.index s k) == false) | Some j -> i <= j /\ p (S.index s j))) (decreases (S.length s - i)) (** Given a sequence [s] all of whose elements are at most [n], if the length of [s] is greater than [n], then there are two distinct indexes in [s] that contain the same element *) val pigeonhole (#n: pos) (s: S.seq (under n)) : Pure (in_ s * in_ s) (requires S.length s = n + 1) (ensures (fun (i1, i2) -> i1 < i2 /\ S.index s i1 = S.index s i2)) (decreases n) (** Here we prepare to prove pigeonhole principle for a finite sequence with a custom equivalence relation (as opposed to eqtype). Think setoids. *) (** Following code is extracted from CuteCAS, which will eventually make its way into F* -- when I wrap things up with most important notions of abstract algebra. As I port more code from my CAS project to F*, such things will be moved to separate modules. -- Alex Rozanov *) inline_for_extraction type binary_relation (a: Type) = a -> a -> bool (** For performance reasons, forall definitions are best kept hidden from SMT. Use reveal_opaque when you really need it. Or use refl/trans/symm lemmas below to keep the context clean. *) val is_reflexive (#a:Type) (r: binary_relation a) : Type0 val is_symmetric (#a:Type) (r: binary_relation a) : Type0 val is_transitive (#a:Type) (r: binary_relation a) : Type0 val is_reflexive_intro (#a:Type) (r: binary_relation a) : Lemma (requires forall (x:a). r x x) (ensures is_reflexive r) val is_symmetric_intro (#a:Type) (r: binary_relation a) : Lemma (requires forall (x:a). r x x) (ensures is_reflexive r) val is_transitive_intro (#a:Type) (r: binary_relation a) : Lemma (requires forall (x:a). r x x) (ensures is_reflexive r) (** Textbook stuff on equivalence relations *) type equivalence_relation (a: Type) = r:binary_relation a { is_reflexive r /\ is_symmetric r /\ is_transitive r } val refl_lemma (#a:Type) (eq: equivalence_relation a) (x:a) : Lemma (eq x x) val symm_lemma (#a:Type) (eq:equivalence_relation a) (x y:a) : Lemma (eq x y == eq y x) val trans_lemma (#a:Type) (eq: equivalence_relation a) (x y z:a) : Lemma (requires (eq x y \/ eq y x) /\ (eq y z \/ eq z y)) (ensures (x `eq` z) && (z `eq` x)) (** (contains) predicate, but with custom comparison operation (a->a->bool) *) [@@"opaque_to_smt"]
false
false
FStar.Fin.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_eq : eq: FStar.Fin.equivalence_relation a -> s: FStar.Seq.Base.seq a -> x: a -> Prims.logical
[]
FStar.Fin.contains_eq
{ "file_name": "ulib/FStar.Fin.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
eq: FStar.Fin.equivalence_relation a -> s: FStar.Seq.Base.seq a -> x: a -> Prims.logical
{ "end_col": 53, "end_line": 124, "start_col": 4, "start_line": 124 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let vect (n: nat) (a: Type) = l: list a {L.length l = n}
let vect (n: nat) (a: Type) =
false
null
false
l: list a {L.length l = n}
{ "checked_file": "FStar.Fin.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.Fin.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.list", "Prims.b2t", "Prims.op_Equality", "FStar.List.Tot.Base.length" ]
[]
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Fin /// This module is supposed to contain various lemmas about /// finiteness. For now, it mainly provides a basic pigeonhole /// principle /// /// TODO: We might generalize this to also support general utilities /// for reasoning about cardinality, relation with injections and /// surjections, etc. /// /// UPD. November 8, 2022 -- added support for custom equivalence relation-aware /// pigeon principle lemma. /// UPD. November 23, 2022 -- added interface file module L = FStar.List.Tot module S = FStar.Seq (** The type of natural numbers bounded by [n] *) inline_for_extraction let fin (n: nat) = k: int {0 <= k /\ k < n} (** Newer synonym. We perhaps should choose one over another globally. [under] is also defined in IntegerIntervals.fst, along with other often used finite intervals. *) inline_for_extraction let under (p:nat) = x:nat {x<p} (** Length-indexed list *)
false
true
FStar.Fin.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 vect : n: Prims.nat -> a: Type -> Type
[]
FStar.Fin.vect
{ "file_name": "ulib/FStar.Fin.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> a: Type -> Type
{ "end_col": 56, "end_line": 46, "start_col": 30, "start_line": 46 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Seq", "short_module": "S" }, { "abbrev": true, "full_module": "FStar.List.Tot", "short_module": "L" }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let seqn (n: nat) (a: Type) = s: S.seq a {S.length s = n}
let seqn (n: nat) (a: Type) =
false
null
false
s: S.seq a {S.length s = n}
{ "checked_file": "FStar.Fin.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.List.Tot.fst.checked" ], "interface_file": false, "source_file": "FStar.Fin.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.Seq.Base.seq", "Prims.b2t", "Prims.op_Equality", "FStar.Seq.Base.length" ]
[]
(* Copyright 2008-2022 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.Fin /// This module is supposed to contain various lemmas about /// finiteness. For now, it mainly provides a basic pigeonhole /// principle /// /// TODO: We might generalize this to also support general utilities /// for reasoning about cardinality, relation with injections and /// surjections, etc. /// /// UPD. November 8, 2022 -- added support for custom equivalence relation-aware /// pigeon principle lemma. /// UPD. November 23, 2022 -- added interface file module L = FStar.List.Tot module S = FStar.Seq (** The type of natural numbers bounded by [n] *) inline_for_extraction let fin (n: nat) = k: int {0 <= k /\ k < n} (** Newer synonym. We perhaps should choose one over another globally. [under] is also defined in IntegerIntervals.fst, along with other often used finite intervals. *) inline_for_extraction let under (p:nat) = x:nat {x<p} (** Length-indexed list *) inline_for_extraction let vect (n: nat) (a: Type) = l: list a {L.length l = n} (** Length-indexed sequence *)
false
true
FStar.Fin.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 seqn : n: Prims.nat -> a: Type -> Type
[]
FStar.Fin.seqn
{ "file_name": "ulib/FStar.Fin.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> a: Type -> Type
{ "end_col": 57, "end_line": 50, "start_col": 30, "start_line": 50 }
Prims.Tot
val min_int (n: nat) : Tot int
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let min_int (n:nat) : Tot int = 0
val min_int (n: nat) : Tot int let min_int (n: nat) : Tot int =
false
null
false
0
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.int" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus
false
true
FStar.UInt.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 min_int (n: nat) : Tot int
[]
FStar.UInt.min_int
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> Prims.int
{ "end_col": 33, "end_line": 47, "start_col": 32, "start_line": 47 }
Prims.Tot
val size (x: int) (n: nat) : Tot Type0
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n)
val size (x: int) (n: nat) : Tot Type0 let size (x: int) (n: nat) : Tot Type0 =
false
null
false
b2t (fits x n)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.int", "Prims.nat", "Prims.b2t", "FStar.UInt.fits" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0
false
true
FStar.UInt.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 size (x: int) (n: nat) : Tot Type0
[]
FStar.UInt.size
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: Prims.int -> n: Prims.nat -> Type0
{ "end_col": 52, "end_line": 50, "start_col": 39, "start_line": 50 }
Prims.Tot
val fits (x: int) (n: nat) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n
val fits (x: int) (n: nat) : Tot bool let fits (x: int) (n: nat) : Tot bool =
false
null
false
min_int n <= x && x <= max_int n
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.int", "Prims.nat", "Prims.op_AmpAmp", "Prims.op_LessThanOrEqual", "FStar.UInt.min_int", "FStar.UInt.max_int", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0
false
true
FStar.UInt.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 fits (x: int) (n: nat) : Tot bool
[]
FStar.UInt.fits
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
x: Prims.int -> n: Prims.nat -> Prims.bool
{ "end_col": 70, "end_line": 49, "start_col": 38, "start_line": 49 }
Prims.Tot
val max_int (n: nat) : Tot int
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let max_int (n:nat) : Tot int = pow2 n - 1
val max_int (n: nat) : Tot int let max_int (n: nat) : Tot int =
false
null
false
pow2 n - 1
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.op_Subtraction", "Prims.pow2", "Prims.int" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus
false
true
FStar.UInt.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 max_int (n: nat) : Tot int
[]
FStar.UInt.max_int
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> Prims.int
{ "end_col": 42, "end_line": 46, "start_col": 32, "start_line": 46 }
Prims.Tot
val gte (#n: _) (a b: uint_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b)
val gte (#n: _) (a b: uint_t n) : Tot bool let gte #n (a: uint_t n) (b: uint_t n) : Tot bool =
false
null
false
(a >= b)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_GreaterThanOrEqual", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b)
false
false
FStar.UInt.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 gte (#n: _) (a b: uint_t n) : Tot bool
[]
FStar.UInt.gte
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.bool
{ "end_col": 58, "end_line": 167, "start_col": 50, "start_line": 167 }
Prims.Tot
val gt (#n: _) (a b: uint_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b)
val gt (#n: _) (a b: uint_t n) : Tot bool let gt #n (a: uint_t n) (b: uint_t n) : Tot bool =
false
null
false
(a > b)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_GreaterThan", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *)
false
false
FStar.UInt.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 gt (#n: _) (a b: uint_t n) : Tot bool
[]
FStar.UInt.gt
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.bool
{ "end_col": 56, "end_line": 166, "start_col": 49, "start_line": 166 }
Prims.Tot
val lte (#n: _) (a b: uint_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b)
val lte (#n: _) (a b: uint_t n) : Tot bool let lte #n (a: uint_t n) (b: uint_t n) : Tot bool =
false
null
false
(a <= b)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_LessThanOrEqual", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b)
false
false
FStar.UInt.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 lte (#n: _) (a b: uint_t n) : Tot bool
[]
FStar.UInt.lte
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.bool
{ "end_col": 58, "end_line": 169, "start_col": 50, "start_line": 169 }
Prims.Tot
val lt (#n: _) (a b: uint_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b)
val lt (#n: _) (a b: uint_t n) : Tot bool let lt #n (a: uint_t n) (b: uint_t n) : Tot bool =
false
null
false
(a < b)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_LessThan", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b)
false
false
FStar.UInt.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 lt (#n: _) (a b: uint_t n) : Tot bool
[]
FStar.UInt.lt
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.bool
{ "end_col": 56, "end_line": 168, "start_col": 49, "start_line": 168 }
Prims.Tot
val xor (b b': bool) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let xor (b:bool) (b':bool) : Tot bool = b <> b'
val xor (b b': bool) : Tot bool let xor (b b': bool) : Tot bool =
false
null
false
b <> b'
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.bool", "Prims.op_disEquality" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos) (a:uint_t n) : Tot (uint_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logand #n (logand #n a b) c = logand #n a (logand #n b c))) val logand_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a a = a)) val logand_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (ones n) = a)) (* subset_vec_le_lemma proves that a subset of bits is numerically smaller or equal. *) val subset_vec_le_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_subset_vec #n a b) (ensures (from_vec a) <= (from_vec b)) (* logand_le proves the the result of AND is less than or equal to both arguments. *) val logand_le: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand a b) <= a /\ (logand a b) <= b) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a))
false
true
FStar.UInt.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 xor (b b': bool) : Tot bool
[]
FStar.UInt.xor
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
b: Prims.bool -> b': Prims.bool -> Prims.bool
{ "end_col": 55, "end_line": 380, "start_col": 48, "start_line": 380 }
Prims.Pure
val incr (#n: nat) (a: uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True))
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1
val incr (#n: nat) (a: uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) let incr (#n: nat) (a: uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) =
false
null
false
a + 1
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Addition", "Prims.b2t", "Prims.op_LessThan", "FStar.UInt.max_int", "Prims.l_True" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n)
false
false
FStar.UInt.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 incr (#n: nat) (a: uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True))
[]
FStar.UInt.incr
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
{ "end_col": 9, "end_line": 69, "start_col": 4, "start_line": 69 }
Prims.Tot
val incr_mod (#n: nat) (a: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n)
val incr_mod (#n: nat) (a: uint_t n) : Tot (uint_t n) let incr_mod (#n: nat) (a: uint_t n) : Tot (uint_t n) =
false
null
false
(a + 1) % (pow2 n)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Modulus", "Prims.op_Addition", "Prims.pow2" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b))
false
false
FStar.UInt.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 incr_mod (#n: nat) (a: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.incr_mod
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 72, "end_line": 83, "start_col": 54, "start_line": 83 }
Prims.Pure
val sub (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True))
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b
val sub (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) let sub (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) =
false
null
false
a - b
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Subtraction", "FStar.UInt.size", "Prims.l_True" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n))
false
false
FStar.UInt.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 sub (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True))
[]
FStar.UInt.sub
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
{ "end_col": 9, "end_line": 105, "start_col": 4, "start_line": 105 }
Prims.Tot
val mul_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n)
val mul_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n) let mul_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n) =
false
null
false
(a * b) % (pow2 n)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Modulus", "FStar.Mul.op_Star", "Prims.pow2" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c))
false
false
FStar.UInt.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 mul_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.mul_mod
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 20, "end_line": 127, "start_col": 2, "start_line": 127 }
Prims.Tot
val pow2_n (#n: pos) (p: nat{p < n}) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p
val pow2_n (#n: pos) (p: nat{p < n}) : Tot (uint_t n) let pow2_n (#n: pos) (p: nat{p < n}) : Tot (uint_t n) =
false
null
false
pow2_le_compat (n - 1) p; pow2 p
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "Prims.pow2", "Prims.unit", "FStar.Math.Lemmas.pow2_le_compat", "Prims.op_Subtraction", "FStar.UInt.uint_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0
false
false
FStar.UInt.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 pow2_n (#n: pos) (p: nat{p < n}) : Tot (uint_t n)
[]
FStar.UInt.pow2_n
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
p: Prims.nat{p < n} -> FStar.UInt.uint_t n
{ "end_col": 34, "end_line": 60, "start_col": 2, "start_line": 60 }
Prims.Tot
val zero (n: nat) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let zero (n:nat) : Tot (uint_t n) = 0
val zero (n: nat) : Tot (uint_t n) let zero (n: nat) : Tot (uint_t n) =
false
null
false
0
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants
false
false
FStar.UInt.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 zero (n: nat) : Tot (uint_t n)
[]
FStar.UInt.zero
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> FStar.UInt.uint_t n
{ "end_col": 37, "end_line": 57, "start_col": 36, "start_line": 57 }
Prims.Tot
val one (n: pos) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let one (n:pos) : Tot (uint_t n) = 1
val one (n: pos) : Tot (uint_t n) let one (n: pos) : Tot (uint_t n) =
false
null
false
1
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p
false
false
FStar.UInt.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 one (n: pos) : Tot (uint_t n)
[]
FStar.UInt.one
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.pos -> FStar.UInt.uint_t n
{ "end_col": 36, "end_line": 62, "start_col": 35, "start_line": 62 }
Prims.Pure
val mul (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True))
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b
val mul (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) let mul (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) =
false
null
false
a * b
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[]
[ "Prims.nat", "FStar.UInt.uint_t", "FStar.Mul.op_Star", "FStar.UInt.size", "Prims.l_True" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n))
false
false
FStar.UInt.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 mul (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True))
[]
FStar.UInt.mul
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
{ "end_col": 9, "end_line": 119, "start_col": 4, "start_line": 119 }
Prims.Tot
val add_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n)
val add_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n) let add_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n) =
false
null
false
(a + b) % (pow2 n)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Modulus", "Prims.op_Addition", "Prims.pow2" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c))
false
false
FStar.UInt.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 add_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.add_mod
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 20, "end_line": 99, "start_col": 2, "start_line": 99 }
Prims.Pure
val add (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True))
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b
val add (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) let add (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) =
false
null
false
a + b
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Addition", "FStar.UInt.size", "Prims.l_True" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n))
false
false
FStar.UInt.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 add (#n: nat) (a b: uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True))
[]
FStar.UInt.add
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
{ "end_col": 10, "end_line": 91, "start_col": 5, "start_line": 91 }
Prims.Tot
val to_uint_t (m: nat) (a: int) : Tot (uint_t m)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m
val to_uint_t (m: nat) (a: int) : Tot (uint_t m) let to_uint_t (m: nat) (a: int) : Tot (uint_t m) =
false
null
false
a % pow2 m
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "Prims.int", "Prims.op_Modulus", "Prims.pow2", "FStar.UInt.uint_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts
false
false
FStar.UInt.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 to_uint_t (m: nat) (a: int) : Tot (uint_t m)
[]
FStar.UInt.to_uint_t
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
m: Prims.nat -> a: Prims.int -> FStar.UInt.uint_t m
{ "end_col": 59, "end_line": 173, "start_col": 49, "start_line": 173 }
Prims.Tot
val decr_mod (#n: nat) (a: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n)
val decr_mod (#n: nat) (a: uint_t n) : Tot (uint_t n) let decr_mod (#n: nat) (a: uint_t n) : Tot (uint_t n) =
false
null
false
(a - 1) % (pow2 n)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Modulus", "Prims.op_Subtraction", "Prims.pow2" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n)
false
false
FStar.UInt.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 decr_mod (#n: nat) (a: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.decr_mod
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 72, "end_line": 85, "start_col": 54, "start_line": 85 }
Prims.Tot
val sub_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n)
val sub_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n) let sub_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n) =
false
null
false
(a - b) % (pow2 n)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Modulus", "Prims.op_Subtraction", "Prims.pow2" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c))
false
false
FStar.UInt.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 sub_mod (#n: nat) (a b: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.sub_mod
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 20, "end_line": 113, "start_col": 2, "start_line": 113 }
Prims.Tot
val from_vec (#n: nat) (vec: bv_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0)
val from_vec (#n: nat) (vec: bv_t n) : Tot (uint_t n) let rec from_vec (#n: nat) (vec: bv_t n) : Tot (uint_t n) =
false
null
false
if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.BitVector.bv_t", "Prims.op_Equality", "Prims.int", "Prims.bool", "Prims.op_Addition", "FStar.Mul.op_Star", "FStar.UInt.from_vec", "Prims.op_Subtraction", "FStar.Seq.Base.slice", "FStar.Seq.Base.index", "FStar.UInt.uint_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1))
false
false
FStar.UInt.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 from_vec (#n: nat) (vec: bv_t n) : Tot (uint_t n)
[ "recursion" ]
FStar.UInt.from_vec
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
vec: FStar.BitVector.bv_t n -> FStar.UInt.uint_t n
{ "end_col": 89, "end_line": 186, "start_col": 2, "start_line": 185 }
Prims.Tot
val mod (#n: nat) (a: uint_t n) (b: uint_t n {b <> 0}) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b)
val mod (#n: nat) (a: uint_t n) (b: uint_t n {b <> 0}) : Tot (uint_t n) let mod (#n: nat) (a: uint_t n) (b: uint_t n {b <> 0}) : Tot (uint_t n) =
false
null
false
a - ((a / b) * b)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "Prims.op_Subtraction", "FStar.Mul.op_Star", "Prims.op_Division" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *)
false
false
FStar.UInt.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 mod (#n: nat) (a: uint_t n) (b: uint_t n {b <> 0}) : Tot (uint_t n)
[]
FStar.UInt.mod
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n {b <> 0} -> FStar.UInt.uint_t n
{ "end_col": 17, "end_line": 162, "start_col": 2, "start_line": 162 }
Prims.Tot
val to_vec (#n: nat) (num: uint_t n) : Tot (bv_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1))
val to_vec (#n: nat) (num: uint_t n) : Tot (bv_t n) let rec to_vec (#n: nat) (num: uint_t n) : Tot (bv_t n) =
false
null
false
if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1))
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Equality", "Prims.int", "FStar.Seq.Base.empty", "Prims.bool", "FStar.Seq.Base.append", "FStar.UInt.to_vec", "Prims.op_Subtraction", "Prims.op_Division", "FStar.Seq.Base.create", "Prims.op_Modulus", "FStar.BitVector.bv_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *)
false
false
FStar.UInt.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 to_vec (#n: nat) (num: uint_t n) : Tot (bv_t n)
[ "recursion" ]
FStar.UInt.to_vec
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
num: FStar.UInt.uint_t n -> FStar.BitVector.bv_t n
{ "end_col": 74, "end_line": 182, "start_col": 2, "start_line": 181 }
Prims.Pure
val decr (#n: nat) (a: uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True))
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1
val decr (#n: nat) (a: uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) let decr (#n: nat) (a: uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) =
false
null
false
a - 1
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Subtraction", "Prims.b2t", "Prims.op_GreaterThan", "FStar.UInt.min_int", "Prims.l_True" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n)
false
false
FStar.UInt.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 decr (#n: nat) (a: uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True))
[]
FStar.UInt.decr
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> Prims.Pure (FStar.UInt.uint_t n)
{ "end_col": 9, "end_line": 73, "start_col": 4, "start_line": 73 }
Prims.Tot
val ones (n: nat) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ones (n:nat) : Tot (uint_t n) = max_int n
val ones (n: nat) : Tot (uint_t n) let ones (n: nat) : Tot (uint_t n) =
false
null
false
max_int n
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.max_int", "FStar.UInt.uint_t" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1
false
false
FStar.UInt.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 ones (n: nat) : Tot (uint_t n)
[]
FStar.UInt.ones
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
n: Prims.nat -> FStar.UInt.uint_t n
{ "end_col": 45, "end_line": 64, "start_col": 36, "start_line": 64 }
Prims.Tot
val msb (#n: pos) (a: uint_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let msb (#n:pos) (a:uint_t n) : Tot bool = nth a 0
val msb (#n: pos) (a: uint_t n) : Tot bool let msb (#n: pos) (a: uint_t n) : Tot bool =
false
null
false
nth a 0
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.UInt.nth", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos) (a:uint_t n) : Tot (uint_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logand #n (logand #n a b) c = logand #n a (logand #n b c))) val logand_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a a = a)) val logand_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (ones n) = a)) (* subset_vec_le_lemma proves that a subset of bits is numerically smaller or equal. *) val subset_vec_le_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_subset_vec #n a b) (ensures (from_vec a) <= (from_vec b)) (* logand_le proves the the result of AND is less than or equal to both arguments. *) val logand_le: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand a b) <= a /\ (logand a b) <= b) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) private let xor (b:bool) (b':bool) : Tot bool = b <> b' private val xor_lemma (a:bool) (b:bool) : Lemma (requires (True)) (ensures (xor (xor a b) b = a)) [SMTPat (xor (xor a b) b)] val logxor_inv: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a <> b ==> logxor a b <> 0) (* Bitwise OR operators *) val logor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor #n a b = logor #n b a)) val logor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logor #n (logor #n a b) c = logor #n a (logor #n b c))) val logor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a a = a)) val logor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (zero n) = a)) val logor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (ones n) = ones n)) (* superset_vec_le_lemma proves that a superset of bits is numerically greater than or equal. *) val superset_vec_ge_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_superset_vec #n a b) (ensures (from_vec a) >= (from_vec b)) (* logor_ge proves that the result of an OR is greater than or equal to both arguments. *) val logor_ge: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor a b) >= a /\ (logor a b) >= b) (* Bitwise NOT operator *) val lognot_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (lognot #n (lognot #n a) = a)) val lognot_lemma_1: #n:pos -> Lemma (requires True) (ensures (lognot #n (zero n) = ones n)) (** Used in the next two lemmas *) private val index_to_vec_ones: #n:pos -> m:nat{m <= n} -> i:nat{i < n} -> Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (i < n - m ==> index (to_vec #n (pow2 m - 1)) i == false) /\ (n - m <= i ==> index (to_vec #n (pow2 m - 1)) i == true))) [SMTPat (index (to_vec #n (pow2 m - 1)) i)] val logor_disjoint: #n:pos -> a:uint_t n -> b:uint_t n -> m:pos{m < n} -> Lemma (requires (a % pow2 m == 0 /\ b < pow2 m)) (ensures (logor #n a b == a + b)) val logand_mask: #n:pos -> a:uint_t n -> m:pos{m < n} -> Lemma (pow2 m < pow2 n /\ logand #n a (pow2 m - 1) == a % pow2 m) (* Shift operators *) let shift_left (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_left_vec #n (to_vec #n a) s) let shift_right (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_right_vec #n (to_vec #n a) s) (* Shift operators lemmas *) val shift_left_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = false)) [SMTPat (nth (shift_left #n a s) i)] val shift_left_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = nth #n a (i + s))) [SMTPat (nth (shift_left #n a s) i)] val shift_right_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = false)) [SMTPat (nth (shift_right #n a s) i)] val shift_right_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = nth #n a (i - s))) [SMTPat (nth (shift_right #n a s) i)] (* Lemmas with shift operators and bitwise operators *) val shift_left_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logand #n a b) s = logand #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logand #n a b) s = logand #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logxor #n a b) s = logxor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logxor #n a b) s = logxor #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logor #n a b) s = logor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logor #n a b) s = logor #n (shift_right #n a s) (shift_right #n b s))) (* Lemmas about value after shift operations *) val shift_left_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_left #n a 0 = (a * pow2 0) % pow2 n) val shift_left_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) [SMTPat (shift_left #n a s)] val shift_right_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_right #n a 0 = a / pow2 0) val shift_right_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) [SMTPat (shift_right #n a s)] (* Lemmas about the most significant bit in various situations *)
false
false
FStar.UInt.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 msb (#n: pos) (a: uint_t n) : Tot bool
[]
FStar.UInt.msb
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> Prims.bool
{ "end_col": 50, "end_line": 537, "start_col": 43, "start_line": 537 }
Prims.Tot
val eq (#n: _) (a b: uint_t n) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b)
val eq (#n: _) (a b: uint_t n) : Tot bool let eq #n (a: uint_t n) (b: uint_t n) : Tot bool =
false
null
false
(a = b)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Equality", "Prims.bool" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b)
false
false
FStar.UInt.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 eq (#n: _) (a b: uint_t n) : Tot bool
[]
FStar.UInt.eq
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> Prims.bool
{ "end_col": 56, "end_line": 165, "start_col": 49, "start_line": 165 }
Prims.Tot
val nth (#n: pos) (a: uint_t n) (i: nat{i < n}) : Tot bool
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i
val nth (#n: pos) (a: uint_t n) (i: nat{i < n}) : Tot bool let nth (#n: pos) (a: uint_t n) (i: nat{i < n}) : Tot bool =
false
null
false
index (to_vec #n a) i
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "Prims.nat", "Prims.b2t", "Prims.op_LessThan", "FStar.Seq.Base.index", "Prims.bool", "FStar.UInt.to_vec" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *)
false
false
FStar.UInt.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 nth (#n: pos) (a: uint_t n) (i: nat{i < n}) : Tot bool
[]
FStar.UInt.nth
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> i: Prims.nat{i < n} -> Prims.bool
{ "end_col": 23, "end_line": 270, "start_col": 2, "start_line": 270 }
Prims.Tot
val mul_div (#n: nat) (a b: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n)
val mul_div (#n: nat) (a b: uint_t n) : Tot (uint_t n) let mul_div (#n: nat) (a b: uint_t n) : Tot (uint_t n) =
false
null
false
FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n)
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.op_Division", "FStar.Mul.op_Star", "Prims.pow2", "Prims.unit", "FStar.UInt.lt_square_div_lt", "FStar.Math.Lemmas.lemma_mult_lt_sqr" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0"
false
false
FStar.UInt.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 0, "initial_ifuel": 0, "max_fuel": 0, "max_ifuel": 0, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val mul_div (#n: nat) (a b: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.mul_div
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 20, "end_line": 138, "start_col": 2, "start_line": 136 }
Prims.Tot
val minus (#n: pos) (a: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let minus (#n:pos) (a:uint_t n) : Tot (uint_t n) = add_mod (lognot a) 1
val minus (#n: pos) (a: uint_t n) : Tot (uint_t n) let minus (#n: pos) (a: uint_t n) : Tot (uint_t n) =
false
null
false
add_mod (lognot a) 1
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.UInt.add_mod", "FStar.UInt.lognot" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction
false
false
FStar.UInt.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 minus (#n: pos) (a: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.minus
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 22, "end_line": 334, "start_col": 2, "start_line": 334 }
Prims.Tot
val one_extend (#n: pos) (a: uint_t n) : Tot (uint_t (n + 1))
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let one_extend (#n:pos) (a:uint_t n): Tot (uint_t (n+1)) = from_vec (one_extend_vec (to_vec a))
val one_extend (#n: pos) (a: uint_t n) : Tot (uint_t (n + 1)) let one_extend (#n: pos) (a: uint_t n) : Tot (uint_t (n + 1)) =
false
null
false
from_vec (one_extend_vec (to_vec a))
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.UInt.from_vec", "Prims.op_Addition", "FStar.UInt.one_extend_vec", "FStar.UInt.to_vec" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *) let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b)) let logxor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logxor_vec #n (to_vec #n a) (to_vec #n b)) let logor (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logor_vec #n (to_vec #n a) (to_vec #n b)) let lognot (#n:pos) (a:uint_t n) : Tot (uint_t n) = from_vec #n (lognot_vec #n (to_vec #n a)) (* Bitwise operators definitions *) val logand_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logand a b) i = (nth a i && nth b i))) [SMTPat (nth (logand a b) i)] val logxor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logxor a b) i = (nth a i <> nth b i))) [SMTPat (nth (logxor a b) i)] val logor_definition: #n:pos -> a:uint_t n -> b:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (logor a b) i = (nth a i || nth b i))) [SMTPat (nth (logor a b) i)] val lognot_definition: #n:pos -> a:uint_t n -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (lognot a) i = not(nth a i))) [SMTPat (nth (lognot a) i)] (* Two's complement unary minus *) inline_for_extraction let minus (#n:pos) (a:uint_t n) : Tot (uint_t n) = add_mod (lognot a) 1 (* Bitwise operators lemmas *) (* TODO: lemmas about the relations between different operators *) (* Bitwise AND operator *) val logand_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand #n a b = logand #n b a)) val logand_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logand #n (logand #n a b) c = logand #n a (logand #n b c))) val logand_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a a = a)) val logand_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (zero n) = zero n)) val logand_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logand #n a (ones n) = a)) (* subset_vec_le_lemma proves that a subset of bits is numerically smaller or equal. *) val subset_vec_le_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_subset_vec #n a b) (ensures (from_vec a) <= (from_vec b)) (* logand_le proves the the result of AND is less than or equal to both arguments. *) val logand_le: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logand a b) <= a /\ (logand a b) <= b) (* Bitwise XOR operator *) val logxor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logxor #n a b = logxor #n b a)) val logxor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logxor #n (logxor #n a b) c = logxor #n a (logxor #n b c))) val logxor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a a = zero n)) val logxor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (zero n) = a)) val logxor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logxor #n a (ones n) = lognot #n a)) private let xor (b:bool) (b':bool) : Tot bool = b <> b' private val xor_lemma (a:bool) (b:bool) : Lemma (requires (True)) (ensures (xor (xor a b) b = a)) [SMTPat (xor (xor a b) b)] val logxor_inv: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a = logxor #n (logxor #n a b) b) val logxor_neq_nonzero: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (a <> b ==> logxor a b <> 0) (* Bitwise OR operators *) val logor_commutative: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor #n a b = logor #n b a)) val logor_associative: #n:pos -> a:uint_t n -> b:uint_t n -> c:uint_t n -> Lemma (requires True) (ensures (logor #n (logor #n a b) c = logor #n a (logor #n b c))) val logor_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a a = a)) val logor_lemma_1: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (zero n) = a)) val logor_lemma_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (logor #n a (ones n) = ones n)) (* superset_vec_le_lemma proves that a superset of bits is numerically greater than or equal. *) val superset_vec_ge_lemma: #n:pos -> a:bv_t n -> b:bv_t n -> Lemma (requires is_superset_vec #n a b) (ensures (from_vec a) >= (from_vec b)) (* logor_ge proves that the result of an OR is greater than or equal to both arguments. *) val logor_ge: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires True) (ensures (logor a b) >= a /\ (logor a b) >= b) (* Bitwise NOT operator *) val lognot_self: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures (lognot #n (lognot #n a) = a)) val lognot_lemma_1: #n:pos -> Lemma (requires True) (ensures (lognot #n (zero n) = ones n)) (** Used in the next two lemmas *) private val index_to_vec_ones: #n:pos -> m:nat{m <= n} -> i:nat{i < n} -> Lemma (requires True) (ensures (pow2 m <= pow2 n /\ (i < n - m ==> index (to_vec #n (pow2 m - 1)) i == false) /\ (n - m <= i ==> index (to_vec #n (pow2 m - 1)) i == true))) [SMTPat (index (to_vec #n (pow2 m - 1)) i)] val logor_disjoint: #n:pos -> a:uint_t n -> b:uint_t n -> m:pos{m < n} -> Lemma (requires (a % pow2 m == 0 /\ b < pow2 m)) (ensures (logor #n a b == a + b)) val logand_mask: #n:pos -> a:uint_t n -> m:pos{m < n} -> Lemma (pow2 m < pow2 n /\ logand #n a (pow2 m - 1) == a % pow2 m) (* Shift operators *) let shift_left (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_left_vec #n (to_vec #n a) s) let shift_right (#n:pos) (a:uint_t n) (s:nat) : Tot (uint_t n) = from_vec (shift_right_vec #n (to_vec #n a) s) (* Shift operators lemmas *) val shift_left_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = false)) [SMTPat (nth (shift_left #n a s) i)] val shift_left_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < n - s} -> Lemma (requires True) (ensures (nth (shift_left #n a s) i = nth #n a (i + s))) [SMTPat (nth (shift_left #n a s) i)] val shift_right_lemma_1: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i < s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = false)) [SMTPat (nth (shift_right #n a s) i)] val shift_right_lemma_2: #n:pos -> a:uint_t n -> s:nat -> i:nat{i < n && i >= s} -> Lemma (requires True) (ensures (nth (shift_right #n a s) i = nth #n a (i - s))) [SMTPat (nth (shift_right #n a s) i)] (* Lemmas with shift operators and bitwise operators *) val shift_left_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logand #n a b) s = logand #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logand_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logand #n a b) s = logand #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logxor #n a b) s = logxor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logxor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logxor #n a b) s = logxor #n (shift_right #n a s) (shift_right #n b s))) val shift_left_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_left #n (logor #n a b) s = logor #n (shift_left #n a s) (shift_left #n b s))) val shift_right_logor_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> s:nat -> Lemma (requires True) (ensures (shift_right #n (logor #n a b) s = logor #n (shift_right #n a s) (shift_right #n b s))) (* Lemmas about value after shift operations *) val shift_left_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_left #n a 0 = (a * pow2 0) % pow2 n) val shift_left_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) val shift_left_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_left #n a s = (a * pow2 s) % pow2 n) [SMTPat (shift_left #n a s)] val shift_right_value_aux_1: #n:pos -> a:uint_t n -> s:nat{s >= n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_aux_2: #n:pos -> a:uint_t n -> Lemma (requires True) (ensures shift_right #n a 0 = a / pow2 0) val shift_right_value_aux_3: #n:pos -> a:uint_t n -> s:pos{s < n} -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) val shift_right_value_lemma: #n:pos -> a:uint_t n -> s:nat -> Lemma (requires True) (ensures shift_right #n a s = a / pow2 s) [SMTPat (shift_right #n a s)] (* Lemmas about the most significant bit in various situations *) let msb (#n:pos) (a:uint_t n) : Tot bool = nth a 0 val lemma_msb_pow2: #n:pos -> a:uint_t n -> Lemma (msb a <==> a >= pow2 (n-1)) val lemma_minus_zero: #n:pos -> a:uint_t n -> Lemma (minus a = 0 ==> a = 0) val lemma_msb_gte: #n:pos{n > 1} -> a:uint_t n -> b:uint_t n -> Lemma ((a >= b && not (msb a)) ==> not (msb b)) (* Lemmas toward showing ~n + 1 = -a *) val lemma_uint_mod: #n:pos -> a:uint_t n -> Lemma (a = a % pow2 n) val lemma_add_sub_cancel: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (add_mod (sub_mod a b) b = a) val lemma_mod_sub_distr_l: a:int -> b:int -> p:pos -> Lemma ((a - b) % p = ((a % p) - b) % p) val lemma_sub_add_cancel: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (sub_mod (add_mod a b) b = a) let zero_extend_vec (#n:pos) (a:BitVector.bv_t n): Tot (BitVector.bv_t (n+1)) = Seq.append (Seq.create 1 false) a let one_extend_vec (#n:pos) (a:BitVector.bv_t n): Tot (BitVector.bv_t (n+1)) = Seq.append (Seq.create 1 true) a
false
false
FStar.UInt.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 one_extend (#n: pos) (a: uint_t n) : Tot (uint_t (n + 1))
[]
FStar.UInt.one_extend
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> FStar.UInt.uint_t (n + 1)
{ "end_col": 95, "end_line": 567, "start_col": 59, "start_line": 567 }
Prims.Tot
val logand (#n: pos) (a b: uint_t n) : Tot (uint_t n)
[ { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let logand (#n:pos) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b))
val logand (#n: pos) (a b: uint_t n) : Tot (uint_t n) let logand (#n: pos) (a b: uint_t n) : Tot (uint_t n) =
false
null
false
from_vec #n (logand_vec #n (to_vec #n a) (to_vec #n b))
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "FStar.UInt.from_vec", "FStar.BitVector.logand_vec", "FStar.UInt.to_vec" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n)) let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b (* Modulo primitives *) let mod (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (uint_t n) = a - ((a/b) * b) (* Comparison operators *) let eq #n (a:uint_t n) (b:uint_t n) : Tot bool = (a = b) let gt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a > b) let gte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a >= b) let lt #n (a:uint_t n) (b:uint_t n) : Tot bool = (a < b) let lte #n (a:uint_t n) (b:uint_t n) : Tot bool = (a <= b) /// Casts let to_uint_t (m:nat) (a:int) : Tot (uint_t m) = a % pow2 m open FStar.Seq (* WARNING: Mind the big endian vs little endian definition *) (* Casts *) let rec to_vec (#n:nat) (num:uint_t n) : Tot (bv_t n) = if n = 0 then Seq.empty #bool else Seq.append (to_vec #(n - 1) (num / 2)) (Seq.create 1 (num % 2 = 1)) let rec from_vec (#n:nat) (vec:bv_t n) : Tot (uint_t n) = if n = 0 then 0 else 2 * from_vec #(n - 1) (slice vec 0 (n - 1)) + (if index vec (n - 1) then 1 else 0) val to_vec_lemma_1: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires a = b) (ensures equal (to_vec a) (to_vec b)) val to_vec_lemma_2: #n:nat -> a:uint_t n -> b:uint_t n -> Lemma (requires equal (to_vec a) (to_vec b)) (ensures a = b) val inverse_aux: #n:nat -> vec:bv_t n -> i:nat{i < n} -> Lemma (requires True) (ensures index vec i = index (to_vec (from_vec vec)) i) [SMTPat (index (to_vec (from_vec vec)) i)] val inverse_vec_lemma: #n:nat -> vec:bv_t n -> Lemma (requires True) (ensures equal vec (to_vec (from_vec vec))) [SMTPat (to_vec (from_vec vec))] val inverse_num_lemma: #n:nat -> num:uint_t n -> Lemma (requires True) (ensures num = from_vec (to_vec num)) [SMTPat (from_vec (to_vec num))] val from_vec_lemma_1: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires equal a b) (ensures from_vec a = from_vec b) val from_vec_lemma_2: #n:nat -> a:bv_t n -> b:bv_t n -> Lemma (requires from_vec a = from_vec b) (ensures equal a b) val from_vec_aux: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> s2:nat{s2 < s1} -> Lemma (requires True) (ensures (from_vec #s2 (slice a 0 s2)) * pow2 (n - s2) + (from_vec #(s1 - s2) (slice a s2 s1)) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n)) = ((from_vec #s2 (slice a 0 s2)) * pow2 (s1 - s2) + (from_vec #(s1 - s2) (slice a s2 s1))) * pow2 (n - s1) + (from_vec #(n - s1) (slice a s1 n))) val seq_slice_lemma: #n:nat -> a:bv_t n -> s1:nat{s1 < n} -> t1:nat{t1 >= s1 && t1 <= n} -> s2:nat{s2 < t1 - s1} -> t2:nat{t2 >= s2 && t2 <= t1 - s1} -> Lemma (equal (slice (slice a s1 t1) s2 t2) (slice a (s1 + s2) (s1 + t2))) val from_vec_propriety: #n:pos -> a:bv_t n -> s:nat{s < n} -> Lemma (requires True) (ensures from_vec a = (from_vec #s (slice a 0 s)) * pow2 (n - s) + from_vec #(n - s) (slice a s n)) (decreases (n - s)) val append_lemma: #n:pos -> #m:pos -> a:bv_t n -> b:bv_t m -> Lemma (from_vec #(n + m) (append a b) = (from_vec #n a) * pow2 m + (from_vec #m b)) val slice_left_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a 0 s) = (from_vec #n a) / (pow2 (n - s))) val slice_right_lemma: #n:pos -> a:bv_t n -> s:pos{s < n} -> Lemma (requires True) (ensures from_vec #s (slice a (n - s) n) = (from_vec #n a) % (pow2 s)) (* Relations between constants in BitVector and in UInt. *) val zero_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (zero n)) i = index (zero_vec #n) i) [SMTPat (index (to_vec (zero n)) i)] val zero_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (zero_vec #n) = zero n) [SMTPat (from_vec (zero_vec #n))] val one_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (one n)) i = index (elem_vec #n (n - 1)) i) [SMTPat (index (to_vec (one n)) i)] val pow2_to_vec_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (pow2_n #n p)) i = index (elem_vec #n (n - p - 1)) i) [SMTPat (index (to_vec (pow2_n #n p)) i)] val pow2_from_vec_lemma: #n:pos -> p:nat{p < n} -> Lemma (requires True) (ensures from_vec (elem_vec #n p) = pow2_n #n (n - p - 1)) [SMTPat (from_vec (elem_vec #n p))] val ones_to_vec_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures index (to_vec (ones n)) i = index (ones_vec #n) i) [SMTPat (index (to_vec (ones n)) i)] val ones_from_vec_lemma: #n:pos -> Lemma (requires True) (ensures from_vec (ones_vec #n) = ones n) [SMTPat (from_vec (ones_vec #n))] (* (nth a i) returns a boolean indicating the i-th bit of a. *) let nth (#n:pos) (a:uint_t n) (i:nat{i < n}) : Tot bool = index (to_vec #n a) i val nth_lemma: #n:pos -> a:uint_t n -> b:uint_t n -> Lemma (requires forall (i:nat{i < n}). nth a i = nth b i) (ensures a = b) (* Lemmas for constants *) val zero_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures nth (zero n) i = false) [SMTPat (nth (zero n) i)] val pow2_nth_lemma: #n:pos -> p:nat{p < n} -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - p - 1 ==> nth (pow2_n #n p) i = true) /\ (i <> n - p - 1 ==> nth (pow2_n #n p) i = false)) [SMTPat (nth (pow2_n #n p) i)] val one_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (i = n - 1 ==> nth (one n) i = true) /\ (i < n - 1 ==> nth (one n) i = false)) [SMTPat (nth (one n) i)] val ones_nth_lemma: #n:pos -> i:nat{i < n} -> Lemma (requires True) (ensures (nth (ones n) i) = true) [SMTPat (nth (ones n) i)] (* Bitwise operators *)
false
false
FStar.UInt.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 logand (#n: pos) (a b: uint_t n) : Tot (uint_t n)
[]
FStar.UInt.logand
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n -> FStar.UInt.uint_t n
{ "end_col": 57, "end_line": 299, "start_col": 2, "start_line": 299 }
Prims.Tot
val udiv (#n: pos) (a: uint_t n) (b: uint_t n {b <> 0}) : Tot (c: uint_t n {b <> 0 ==> a / b = c})
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let udiv (#n:pos) (a:uint_t n) (b:uint_t n{b <> 0}) : Tot (c:uint_t n{b <> 0 ==> a / b = c}) = div_size #n a b; a / b
val udiv (#n: pos) (a: uint_t n) (b: uint_t n {b <> 0}) : Tot (c: uint_t n {b <> 0 ==> a / b = c}) let udiv (#n: pos) (a: uint_t n) (b: uint_t n {b <> 0}) : Tot (c: uint_t n {b <> 0 ==> a / b = c}) =
false
null
false
div_size #n a b; a / b
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[ "total" ]
[ "Prims.pos", "FStar.UInt.uint_t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "Prims.op_Division", "Prims.unit", "FStar.UInt.div_size", "Prims.l_imp", "Prims.op_Equality" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b val div_underspec: #n:nat -> a:uint_t n -> b:uint_t n{b <> 0} -> Pure (uint_t n) (requires True) (ensures (fun c -> (b <> 0 /\ size (a / b) n) ==> a / b = c)) val div_size: #n:pos -> a:uint_t n -> b:uint_t n{b <> 0} -> Lemma (requires (size a n)) (ensures (size (a / b) n))
false
false
FStar.UInt.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 udiv (#n: pos) (a: uint_t n) (b: uint_t n {b <> 0}) : Tot (c: uint_t n {b <> 0 ==> a / b = c})
[]
FStar.UInt.udiv
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n {b <> 0} -> c: FStar.UInt.uint_t n {b <> 0 ==> a / b = c}
{ "end_col": 7, "end_line": 157, "start_col": 2, "start_line": 156 }
Prims.Pure
val div (#n: nat) (a: uint_t n) (b: uint_t n {b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c))
[ { "abbrev": false, "full_module": "FStar.Math.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "FStar.BitVector", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) = a / b
val div (#n: nat) (a: uint_t n) (b: uint_t n {b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) let div (#n: nat) (a: uint_t n) (b: uint_t n {b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c)) =
false
null
false
a / b
{ "checked_file": "FStar.UInt.fsti.checked", "dependencies": [ "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked", "FStar.Math.Lemmas.fst.checked", "FStar.BitVector.fst.checked" ], "interface_file": false, "source_file": "FStar.UInt.fsti" }
[]
[ "Prims.nat", "FStar.UInt.uint_t", "Prims.b2t", "Prims.op_disEquality", "Prims.int", "Prims.op_Division", "FStar.UInt.size", "Prims.l_imp", "Prims.op_Equality" ]
[]
(* Copyright 2008-2018 Microsoft Research Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *) module FStar.UInt (* NOTE: anything that you fix/update here should be reflected in [FStar.Int.fsti], which is mostly * a copy-paste of this module. *) open FStar.Mul open FStar.BitVector open FStar.Math.Lemmas val pow2_values: x:nat -> Lemma (let p = pow2 x in match x with | 0 -> p=1 | 1 -> p=2 | 8 -> p=256 | 16 -> p=65536 | 31 -> p=2147483648 | 32 -> p=4294967296 | 63 -> p=9223372036854775808 | 64 -> p=18446744073709551616 | 128 -> p=0x100000000000000000000000000000000 | _ -> True) [SMTPat (pow2 x)] /// Specs /// /// Note: lacking any type of functors for F*, this is a copy/paste of [FStar.Int.fst], where the relevant bits that changed are: /// - definition of max and min /// - use of regular integer modulus instead of wrap-around modulus let max_int (n:nat) : Tot int = pow2 n - 1 let min_int (n:nat) : Tot int = 0 let fits (x:int) (n:nat) : Tot bool = min_int n <= x && x <= max_int n let size (x:int) (n:nat) : Tot Type0 = b2t(fits x n) (* Machine integer type *) type uint_t (n:nat) = x:int{size x n} /// Constants let zero (n:nat) : Tot (uint_t n) = 0 let pow2_n (#n:pos) (p:nat{p < n}) : Tot (uint_t n) = pow2_le_compat (n - 1) p; pow2 p let one (n:pos) : Tot (uint_t n) = 1 let ones (n:nat) : Tot (uint_t n) = max_int n (* Increment and decrement *) let incr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun _ -> True)) = a + 1 let decr (#n:nat) (a:uint_t n) : Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun _ -> True)) = a - 1 val incr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a < max_int n))) (ensures (fun b -> a + 1 = b)) val decr_underspec: #n:nat -> a:uint_t n -> Pure (uint_t n) (requires (b2t (a > min_int n))) (ensures (fun b -> a - 1 = b)) let incr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a + 1) % (pow2 n) let decr_mod (#n:nat) (a:uint_t n) : Tot (uint_t n) = (a - 1) % (pow2 n) (* Addition primitives *) let add (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a + b) n)) (ensures (fun _ -> True)) = a + b val add_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a + b) n ==> a + b = c)) let add_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a + b) % (pow2 n) (* Subtraction primitives *) let sub (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a - b) n)) (ensures (fun _ -> True)) = a - b val sub_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a - b) n ==> a - b = c)) let sub_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a - b) % (pow2 n) (* Multiplication primitives *) let mul (#n:nat) (a:uint_t n) (b:uint_t n) : Pure (uint_t n) (requires (size (a * b) n)) (ensures (fun _ -> True)) = a * b val mul_underspec: #n:nat -> a:uint_t n -> b:uint_t n -> Pure (uint_t n) (requires True) (ensures (fun c -> size (a * b) n ==> a * b = c)) let mul_mod (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = (a * b) % (pow2 n) private val lt_square_div_lt (a:nat) (b:pos) : Lemma (requires (a < b * b)) (ensures (a / b < b)) #push-options "--fuel 0 --ifuel 0" let mul_div (#n:nat) (a:uint_t n) (b:uint_t n) : Tot (uint_t n) = FStar.Math.Lemmas.lemma_mult_lt_sqr a b (pow2 n); lt_square_div_lt (a * b) (pow2 n); (a * b) / (pow2 n) #pop-options (* Division primitives *) let div (#n:nat) (a:uint_t n) (b:uint_t n{b <> 0}) : Pure (uint_t n) (requires (size (a / b) n))
false
false
FStar.UInt.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 div (#n: nat) (a: uint_t n) (b: uint_t n {b <> 0}) : Pure (uint_t n) (requires (size (a / b) n)) (ensures (fun c -> b <> 0 ==> a / b = c))
[]
FStar.UInt.div
{ "file_name": "ulib/FStar.UInt.fsti", "git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f", "git_url": "https://github.com/FStarLang/FStar.git", "project_name": "FStar" }
a: FStar.UInt.uint_t n -> b: FStar.UInt.uint_t n {b <> 0} -> Prims.Pure (FStar.UInt.uint_t n)
{ "end_col": 9, "end_line": 145, "start_col": 4, "start_line": 145 }