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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.HyperStack.ST.Stack | val point_add: p:F51.point -> q:F51.point -> out:F51.point ->
Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint p q /\
eq_or_disjoint p out /\ eq_or_disjoint q out /\
F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p) /\
F51.point_inv_t h q /\ F51.inv_ext_point (as_seq h q))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\
F51.point_eval h1 out ==
SE.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Ed25519.Ladder",
"short_module": "ML"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "SC"
},
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Ed25519.Field51",
"short_module": "F51"
},
{
"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.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_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 p q out =
let h0 = ST.get () in
Spec.Ed25519.Lemmas.to_aff_point_add_lemma
(F51.refl_ext_point (as_seq h0 p))
(F51.refl_ext_point (as_seq h0 q));
Hacl.Impl.Ed25519.PointAdd.point_add out p q | val point_add: p:F51.point -> q:F51.point -> out:F51.point ->
Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint p q /\
eq_or_disjoint p out /\ eq_or_disjoint q out /\
F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p) /\
F51.point_inv_t h q /\ F51.inv_ext_point (as_seq h q))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\
F51.point_eval h1 out ==
SE.point_add (F51.point_eval h0 p) (F51.point_eval h0 q))
let point_add p q out = | true | null | false | let h0 = ST.get () in
Spec.Ed25519.Lemmas.to_aff_point_add_lemma (F51.refl_ext_point (as_seq h0 p))
(F51.refl_ext_point (as_seq h0 q));
Hacl.Impl.Ed25519.PointAdd.point_add out p q | {
"checked_file": "Hacl.EC.Ed25519.fst.checked",
"dependencies": [
"Spec.Ed25519.Lemmas.fsti.checked",
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Ed25519.PointNegate.fst.checked",
"Hacl.Impl.Ed25519.PointEqual.fst.checked",
"Hacl.Impl.Ed25519.PointDouble.fst.checked",
"Hacl.Impl.Ed25519.PointDecompress.fst.checked",
"Hacl.Impl.Ed25519.PointConstants.fst.checked",
"Hacl.Impl.Ed25519.PointCompress.fst.checked",
"Hacl.Impl.Ed25519.PointAdd.fst.checked",
"Hacl.Impl.Ed25519.Ladder.fsti.checked",
"Hacl.Impl.Ed25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"Hacl.Bignum25519.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.EC.Ed25519.fst"
} | [] | [
"Hacl.Impl.Ed25519.Field51.point",
"Hacl.Impl.Ed25519.PointAdd.point_add",
"Prims.unit",
"Spec.Ed25519.Lemmas.to_aff_point_add_lemma",
"Hacl.Impl.Ed25519.Field51.refl_ext_point",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.EC.Ed25519
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module F51 = Hacl.Impl.Ed25519.Field51
module SE = Spec.Ed25519
module SC = Spec.Curve25519
module ML = Hacl.Impl.Ed25519.Ladder
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@@ CPrologue
"/*******************************************************************************
Verified field arithmetic modulo p = 2^255 - 19.
This is a 64-bit optimized version, where a field element in radix-2^{51} is
represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5].
*******************************************************************************/\n";
Comment "Write the additive identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_zero: b:F51.felem ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
F51.mul_inv_t h1 b /\
F51.fevalh h1 b == SC.zero)
let mk_felem_zero b =
Hacl.Bignum25519.make_zero b
[@@ Comment "Write the multiplicative identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_one: b:F51.felem ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
F51.mul_inv_t h1 b /\
F51.fevalh h1 b == SC.one)
let mk_felem_one b =
Hacl.Bignum25519.make_one b
[@@ Comment "Write `a + b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
(disjoint out a \/ out == a) /\
(disjoint out b \/ out == b) /\
(disjoint a b \/ a == b) /\
F51.mul_inv_t h a /\
F51.mul_inv_t h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b))
let felem_add a b out =
Hacl.Impl.Curve25519.Field51.fadd out a b;
Hacl.Bignum25519.reduce_513 out
[@@ Comment "Write `a - b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
(disjoint out a \/ out == a) /\
(disjoint out b \/ out == b) /\
(disjoint a b \/ a == b) /\
F51.mul_inv_t h a /\
F51.mul_inv_t h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b))
let felem_sub a b out =
Hacl.Impl.Curve25519.Field51.fsub out a b;
Hacl.Bignum25519.reduce_513 out
[@@ Comment "Write `a * b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
F51.mul_inv_t h a /\
F51.mul_inv_t h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b))
let felem_mul a b out =
push_frame();
let tmp = create 10ul (u128 0) in
Hacl.Impl.Curve25519.Field51.fmul out a b tmp;
pop_frame()
[@@ Comment "Write `a * a mod p` in `out`.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are either disjoint or equal"]
val felem_sqr: a:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h out /\
F51.mul_inv_t h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a))
let felem_sqr a out =
push_frame();
let tmp = create 5ul (u128 0) in
Hacl.Impl.Curve25519.Field51.fsqr out a tmp;
pop_frame()
[@@ Comment "Write `a ^ (p - 2) mod p` in `out`.
The function computes modular multiplicative inverse if `a` <> zero.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_inv: a:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F51.mul_inv_t h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2))
let felem_inv a out =
Hacl.Bignum25519.inverse out a;
Hacl.Bignum25519.reduce_513 out
[@@ Comment "Load a little-endian field element from memory.
The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32].
The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `b` and `out` are disjoint
NOTE that the function also performs the reduction modulo 2^255."]
val felem_load: b:lbuffer uint8 32ul -> out:F51.felem ->
Stack unit
(requires fun h -> live h b /\ live h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255)
let felem_load b out =
Hacl.Bignum25519.load_51 out b
[@@ Comment "Serialize a field element into little-endian memory.
The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5].
The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_store: a:F51.felem -> out:lbuffer uint8 32ul ->
Stack unit
(requires fun h ->
live h a /\ live h out /\
F51.mul_inv_t h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a))
let felem_store a out =
Hacl.Bignum25519.store_51 out a
[@@ CPrologue
"/*******************************************************************************
Verified group operations for the edwards25519 elliptic curve of the form
−x^2 + y^2 = 1 − (121665/121666) * x^2 * y^2.
This is a 64-bit optimized version, where a group element in extended homogeneous
coordinates (X, Y, Z, T) is represented as an array of 20 unsigned 64-bit
integers, i.e., uint64_t[20].
*******************************************************************************/\n";
Comment "Write the point at infinity (additive identity) in `p`.
The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."]
val mk_point_at_inf: p:F51.point ->
Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\
SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity)
let mk_point_at_inf p =
Hacl.Impl.Ed25519.PointConstants.make_point_inf p
[@@ Comment "Write the base point (generator) in `p`.
The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."]
val mk_base_point: p:F51.point ->
Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\
SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g)
let mk_base_point p =
Spec.Ed25519.Lemmas.g_is_on_curve ();
Hacl.Impl.Ed25519.PointConstants.make_g p
[@@ Comment "Write `-p` in `out` (point negation).
The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p` and `out` are disjoint"]
val point_negate: p:F51.point -> out:F51.point ->
Stack unit
(requires fun h ->
live h out /\ live h p /\ disjoint out p /\
F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\
F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p))
let point_negate p out =
let h0 = ST.get () in
Spec.Ed25519.Lemmas.to_aff_point_negate (F51.refl_ext_point (as_seq h0 p));
Hacl.Impl.Ed25519.PointNegate.point_negate p out
[@@ Comment "Write `p + q` in `out` (point addition).
The arguments `p`, `q` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p`, `q`, and `out` are either pairwise disjoint or equal"]
val point_add: p:F51.point -> q:F51.point -> out:F51.point ->
Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint p q /\
eq_or_disjoint p out /\ eq_or_disjoint q out /\
F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p) /\
F51.point_inv_t h q /\ F51.inv_ext_point (as_seq h q))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\
F51.point_eval h1 out ==
SE.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) | false | false | Hacl.EC.Ed25519.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_add: p:F51.point -> q:F51.point -> out:F51.point ->
Stack unit
(requires fun h ->
live h out /\ live h p /\ live h q /\
eq_or_disjoint p q /\
eq_or_disjoint p out /\ eq_or_disjoint q out /\
F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p) /\
F51.point_inv_t h q /\ F51.inv_ext_point (as_seq h q))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\
F51.point_eval h1 out ==
SE.point_add (F51.point_eval h0 p) (F51.point_eval h0 q)) | [] | Hacl.EC.Ed25519.point_add | {
"file_name": "code/ed25519/Hacl.EC.Ed25519.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
p: Hacl.Impl.Ed25519.Field51.point ->
q: Hacl.Impl.Ed25519.Field51.point ->
out: Hacl.Impl.Ed25519.Field51.point
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 46,
"end_line": 301,
"start_col": 23,
"start_line": 296
} |
FStar.HyperStack.ST.Stack | val point_negate: p:F51.point -> out:F51.point ->
Stack unit
(requires fun h ->
live h out /\ live h p /\ disjoint out p /\
F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\
F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p)) | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Ed25519.Ladder",
"short_module": "ML"
},
{
"abbrev": true,
"full_module": "Spec.Curve25519",
"short_module": "SC"
},
{
"abbrev": true,
"full_module": "Spec.Ed25519",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.Ed25519.Field51",
"short_module": "F51"
},
{
"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.EC",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.EC",
"short_module": null
},
{
"abbrev": false,
"full_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_negate p out =
let h0 = ST.get () in
Spec.Ed25519.Lemmas.to_aff_point_negate (F51.refl_ext_point (as_seq h0 p));
Hacl.Impl.Ed25519.PointNegate.point_negate p out | val point_negate: p:F51.point -> out:F51.point ->
Stack unit
(requires fun h ->
live h out /\ live h p /\ disjoint out p /\
F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\
F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p))
let point_negate p out = | true | null | false | let h0 = ST.get () in
Spec.Ed25519.Lemmas.to_aff_point_negate (F51.refl_ext_point (as_seq h0 p));
Hacl.Impl.Ed25519.PointNegate.point_negate p out | {
"checked_file": "Hacl.EC.Ed25519.fst.checked",
"dependencies": [
"Spec.Ed25519.Lemmas.fsti.checked",
"Spec.Ed25519.fst.checked",
"Spec.Curve25519.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Ed25519.PointNegate.fst.checked",
"Hacl.Impl.Ed25519.PointEqual.fst.checked",
"Hacl.Impl.Ed25519.PointDouble.fst.checked",
"Hacl.Impl.Ed25519.PointDecompress.fst.checked",
"Hacl.Impl.Ed25519.PointConstants.fst.checked",
"Hacl.Impl.Ed25519.PointCompress.fst.checked",
"Hacl.Impl.Ed25519.PointAdd.fst.checked",
"Hacl.Impl.Ed25519.Ladder.fsti.checked",
"Hacl.Impl.Ed25519.Field51.fst.checked",
"Hacl.Impl.Curve25519.Field51.fst.checked",
"Hacl.Bignum25519.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.EC.Ed25519.fst"
} | [] | [
"Hacl.Impl.Ed25519.Field51.point",
"Hacl.Impl.Ed25519.PointNegate.point_negate",
"Prims.unit",
"Spec.Ed25519.Lemmas.to_aff_point_negate",
"Hacl.Impl.Ed25519.Field51.refl_ext_point",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.EC.Ed25519
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module F51 = Hacl.Impl.Ed25519.Field51
module SE = Spec.Ed25519
module SC = Spec.Curve25519
module ML = Hacl.Impl.Ed25519.Ladder
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
[@@ CPrologue
"/*******************************************************************************
Verified field arithmetic modulo p = 2^255 - 19.
This is a 64-bit optimized version, where a field element in radix-2^{51} is
represented as an array of five unsigned 64-bit integers, i.e., uint64_t[5].
*******************************************************************************/\n";
Comment "Write the additive identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_zero: b:F51.felem ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
F51.mul_inv_t h1 b /\
F51.fevalh h1 b == SC.zero)
let mk_felem_zero b =
Hacl.Bignum25519.make_zero b
[@@ Comment "Write the multiplicative identity in `f`.
The outparam `f` is meant to be 5 limbs in size, i.e., uint64_t[5]."]
val mk_felem_one: b:F51.felem ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 -> modifies (loc b) h0 h1 /\
F51.mul_inv_t h1 b /\
F51.fevalh h1 b == SC.one)
let mk_felem_one b =
Hacl.Bignum25519.make_one b
[@@ Comment "Write `a + b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_add: a:F51.felem -> b:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
(disjoint out a \/ out == a) /\
(disjoint out b \/ out == b) /\
(disjoint a b \/ a == b) /\
F51.mul_inv_t h a /\
F51.mul_inv_t h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fadd (F51.fevalh h0 a) (F51.fevalh h0 b))
let felem_add a b out =
Hacl.Impl.Curve25519.Field51.fadd out a b;
Hacl.Bignum25519.reduce_513 out
[@@ Comment "Write `a - b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_sub: a:F51.felem -> b:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
(disjoint out a \/ out == a) /\
(disjoint out b \/ out == b) /\
(disjoint a b \/ a == b) /\
F51.mul_inv_t h a /\
F51.mul_inv_t h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fsub (F51.fevalh h0 a) (F51.fevalh h0 b))
let felem_sub a b out =
Hacl.Impl.Curve25519.Field51.fsub out a b;
Hacl.Bignum25519.reduce_513 out
[@@ Comment "Write `a * b mod p` in `out`.
The arguments `a`, `b`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a`, `b`, and `out` are either pairwise disjoint or equal"]
val felem_mul: a:F51.felem -> b:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h out /\
F51.mul_inv_t h a /\
F51.mul_inv_t h b)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 b))
let felem_mul a b out =
push_frame();
let tmp = create 10ul (u128 0) in
Hacl.Impl.Curve25519.Field51.fmul out a b tmp;
pop_frame()
[@@ Comment "Write `a * a mod p` in `out`.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are either disjoint or equal"]
val felem_sqr: a:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h out /\
F51.mul_inv_t h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fmul (F51.fevalh h0 a) (F51.fevalh h0 a))
let felem_sqr a out =
push_frame();
let tmp = create 5ul (u128 0) in
Hacl.Impl.Curve25519.Field51.fsqr out a tmp;
pop_frame()
[@@ Comment "Write `a ^ (p - 2) mod p` in `out`.
The function computes modular multiplicative inverse if `a` <> zero.
The argument `a`, and the outparam `out` are meant to be 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_inv: a:F51.felem -> out:F51.felem ->
Stack unit
(requires fun h ->
live h a /\ live h out /\ disjoint a out /\
F51.mul_inv_t h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.fevalh h1 out == SC.fpow (F51.fevalh h0 a) (SC.prime - 2))
let felem_inv a out =
Hacl.Bignum25519.inverse out a;
Hacl.Bignum25519.reduce_513 out
[@@ Comment "Load a little-endian field element from memory.
The argument `b` points to 32 bytes of valid memory, i.e., uint8_t[32].
The outparam `out` points to a field element of 5 limbs in size, i.e., uint64_t[5].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `b` and `out` are disjoint
NOTE that the function also performs the reduction modulo 2^255."]
val felem_load: b:lbuffer uint8 32ul -> out:F51.felem ->
Stack unit
(requires fun h -> live h b /\ live h out)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.mul_inv_t h1 out /\
F51.as_nat h1 out == Lib.ByteSequence.nat_from_bytes_le (as_seq h0 b) % pow2 255)
let felem_load b out =
Hacl.Bignum25519.load_51 out b
[@@ Comment "Serialize a field element into little-endian memory.
The argument `a` points to a field element of 5 limbs in size, i.e., uint64_t[5].
The outparam `out` points to 32 bytes of valid memory, i.e., uint8_t[32].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `a` and `out` are disjoint"]
val felem_store: a:F51.felem -> out:lbuffer uint8 32ul ->
Stack unit
(requires fun h ->
live h a /\ live h out /\
F51.mul_inv_t h a)
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
as_seq h1 out == Lib.ByteSequence.nat_to_bytes_le 32 (F51.fevalh h0 a))
let felem_store a out =
Hacl.Bignum25519.store_51 out a
[@@ CPrologue
"/*******************************************************************************
Verified group operations for the edwards25519 elliptic curve of the form
−x^2 + y^2 = 1 − (121665/121666) * x^2 * y^2.
This is a 64-bit optimized version, where a group element in extended homogeneous
coordinates (X, Y, Z, T) is represented as an array of 20 unsigned 64-bit
integers, i.e., uint64_t[20].
*******************************************************************************/\n";
Comment "Write the point at infinity (additive identity) in `p`.
The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."]
val mk_point_at_inf: p:F51.point ->
Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\
SE.to_aff_point (F51.point_eval h1 p) == SE.aff_point_at_infinity)
let mk_point_at_inf p =
Hacl.Impl.Ed25519.PointConstants.make_point_inf p
[@@ Comment "Write the base point (generator) in `p`.
The outparam `p` is meant to be 20 limbs in size, i.e., uint64_t[20]."]
val mk_base_point: p:F51.point ->
Stack unit
(requires fun h -> live h p)
(ensures fun h0 _ h1 -> modifies (loc p) h0 h1 /\
F51.point_inv_t h1 p /\ F51.inv_ext_point (as_seq h1 p) /\
SE.to_aff_point (F51.point_eval h1 p) == SE.aff_g)
let mk_base_point p =
Spec.Ed25519.Lemmas.g_is_on_curve ();
Hacl.Impl.Ed25519.PointConstants.make_g p
[@@ Comment "Write `-p` in `out` (point negation).
The argument `p` and the outparam `out` are meant to be 20 limbs in size, i.e., uint64_t[20].
Before calling this function, the caller will need to ensure that the following
precondition is observed.
• `p` and `out` are disjoint"]
val point_negate: p:F51.point -> out:F51.point ->
Stack unit
(requires fun h ->
live h out /\ live h p /\ disjoint out p /\
F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\
F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p)) | false | false | Hacl.EC.Ed25519.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_negate: p:F51.point -> out:F51.point ->
Stack unit
(requires fun h ->
live h out /\ live h p /\ disjoint out p /\
F51.point_inv_t h p /\ F51.inv_ext_point (as_seq h p))
(ensures fun h0 _ h1 -> modifies (loc out) h0 h1 /\
F51.point_inv_t h1 out /\ F51.inv_ext_point (as_seq h1 out) /\
F51.point_eval h1 out == Spec.Ed25519.point_negate (F51.point_eval h0 p)) | [] | Hacl.EC.Ed25519.point_negate | {
"file_name": "code/ed25519/Hacl.EC.Ed25519.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Hacl.Impl.Ed25519.Field51.point -> out: Hacl.Impl.Ed25519.Field51.point
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 50,
"end_line": 273,
"start_col": 24,
"start_line": 270
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_mul_threshold = size K.bn_mul_threshold | let bn_mul_threshold = | false | null | false | size K.bn_mul_threshold | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Lib.IntTypes.size",
"Hacl.Spec.Bignum.Karatsuba.bn_mul_threshold"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.Bignum.Karatsuba.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_mul_threshold : Lib.IntTypes.size_t | [] | Hacl.Bignum.Karatsuba.bn_mul_threshold | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Lib.IntTypes.size_t | {
"end_col": 46,
"end_line": 27,
"start_col": 23,
"start_line": 27
} |
|
Prims.Tot | val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64 | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res | val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res = | false | null | false | bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Prims.unit",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.U64",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Bignum.Karatsuba.bn_karatsuba_mul_open",
"Hacl.Bignum.Karatsuba.bn_karatsuba_mul_uint64"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64 | false | true | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64 | [
"recursion"
] | Hacl.Bignum.Karatsuba.bn_karatsuba_mul_uint64 | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> Hacl.Bignum.Karatsuba.bn_karatsuba_mul_st Lib.IntTypes.U64 | {
"end_col": 64,
"end_line": 259,
"start_col": 2,
"start_line": 259
} |
Prims.Tot | val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32 | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res | val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res = | false | null | false | bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Prims.unit",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Bignum.Karatsuba.bn_karatsuba_mul_open",
"Hacl.Bignum.Karatsuba.bn_karatsuba_mul_uint32"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32 | false | true | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32 | [
"recursion"
] | Hacl.Bignum.Karatsuba.bn_karatsuba_mul_uint32 | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> Hacl.Bignum.Karatsuba.bn_karatsuba_mul_st Lib.IntTypes.U32 | {
"end_col": 64,
"end_line": 254,
"start_col": 2,
"start_line": 254
} |
Prims.Tot | val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_mul_ #t =
match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 () | val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_ #t = | false | null | false | match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 () | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Karatsuba.bn_karatsuba_mul_uint32",
"Hacl.Bignum.Karatsuba.bn_karatsuba_mul_uint64",
"Hacl.Bignum.Karatsuba.bn_karatsuba_mul_st"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res
inline_for_extraction noextract
val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t | false | false | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_mul_ | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Karatsuba.bn_karatsuba_mul_st t | {
"end_col": 37,
"end_line": 267,
"start_col": 2,
"start_line": 265
} |
Prims.Tot | val bn_karatsuba_sqr_: #t:limb_t -> bn_karatsuba_sqr_st t | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_sqr_ #t =
match t with
| U32 -> bn_karatsuba_sqr_uint32 ()
| U64 -> bn_karatsuba_sqr_uint64 () | val bn_karatsuba_sqr_: #t:limb_t -> bn_karatsuba_sqr_st t
let bn_karatsuba_sqr_ #t = | false | null | false | match t with
| U32 -> bn_karatsuba_sqr_uint32 ()
| U64 -> bn_karatsuba_sqr_uint64 () | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_uint32",
"Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_uint64",
"Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_st"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res
inline_for_extraction noextract
val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_ #t =
match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 ()
//TODO: pass tmp as a parameter?
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b))
let bn_karatsuba_mul #t aLen a b res =
push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_mul_ aLen a b tmp res;
pop_frame ()
inline_for_extraction noextract
val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last_sqr #t aLen tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c3 = bn_sub_eq_len_u aLen t01 t23 t45 in
let c5 = c2 -. c3 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t /\ 0 < v len}
-> a:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr_ (v len) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr_open: #t:limb_t -> (self: unit -> bn_karatsuba_sqr_st t) -> bn_karatsuba_sqr_st t
let bn_karatsuba_sqr_open #t (self: unit -> bn_karatsuba_sqr_st t) len a tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_sqr_]]
(K.bn_karatsuba_sqr_ (v len) (as_seq h0 a));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_sqr_u len a res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let t0 = sub tmp 0ul len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
LowStar.Ignore.ignore c0;
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 tmp1 r01;
self () len2 a1 tmp1 r23;
let c = bn_karatsuba_last_sqr len tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_sqr_uint32 : unit -> bn_karatsuba_sqr_st U32
let rec bn_karatsuba_sqr_uint32 () aLen a tmp res =
bn_karatsuba_sqr_open bn_karatsuba_sqr_uint32 aLen a tmp res
val bn_karatsuba_sqr_uint64 : unit -> bn_karatsuba_sqr_st U64
let rec bn_karatsuba_sqr_uint64 () aLen a tmp res =
bn_karatsuba_sqr_open bn_karatsuba_sqr_uint64 aLen a tmp res
inline_for_extraction noextract
val bn_karatsuba_sqr_: #t:limb_t -> bn_karatsuba_sqr_st t | false | false | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_sqr_: #t:limb_t -> bn_karatsuba_sqr_st t | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_ | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_st t | {
"end_col": 37,
"end_line": 388,
"start_col": 2,
"start_line": 386
} |
Prims.Tot | val bn_karatsuba_sqr_uint64 : unit -> bn_karatsuba_sqr_st U64 | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec bn_karatsuba_sqr_uint64 () aLen a tmp res =
bn_karatsuba_sqr_open bn_karatsuba_sqr_uint64 aLen a tmp res | val bn_karatsuba_sqr_uint64 : unit -> bn_karatsuba_sqr_st U64
let rec bn_karatsuba_sqr_uint64 () aLen a tmp res = | false | null | false | bn_karatsuba_sqr_open bn_karatsuba_sqr_uint64 aLen a tmp res | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Prims.unit",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Prims.op_LessThan",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.U64",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_open",
"Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_uint64"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res
inline_for_extraction noextract
val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_ #t =
match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 ()
//TODO: pass tmp as a parameter?
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b))
let bn_karatsuba_mul #t aLen a b res =
push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_mul_ aLen a b tmp res;
pop_frame ()
inline_for_extraction noextract
val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last_sqr #t aLen tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c3 = bn_sub_eq_len_u aLen t01 t23 t45 in
let c5 = c2 -. c3 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t /\ 0 < v len}
-> a:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr_ (v len) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr_open: #t:limb_t -> (self: unit -> bn_karatsuba_sqr_st t) -> bn_karatsuba_sqr_st t
let bn_karatsuba_sqr_open #t (self: unit -> bn_karatsuba_sqr_st t) len a tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_sqr_]]
(K.bn_karatsuba_sqr_ (v len) (as_seq h0 a));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_sqr_u len a res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let t0 = sub tmp 0ul len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
LowStar.Ignore.ignore c0;
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 tmp1 r01;
self () len2 a1 tmp1 r23;
let c = bn_karatsuba_last_sqr len tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_sqr_uint32 : unit -> bn_karatsuba_sqr_st U32
let rec bn_karatsuba_sqr_uint32 () aLen a tmp res =
bn_karatsuba_sqr_open bn_karatsuba_sqr_uint32 aLen a tmp res
val bn_karatsuba_sqr_uint64 : unit -> bn_karatsuba_sqr_st U64 | false | true | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_sqr_uint64 : unit -> bn_karatsuba_sqr_st U64 | [
"recursion"
] | Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_uint64 | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_st Lib.IntTypes.U64 | {
"end_col": 62,
"end_line": 380,
"start_col": 2,
"start_line": 380
} |
Prims.Tot | val bn_karatsuba_sqr_uint32 : unit -> bn_karatsuba_sqr_st U32 | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec bn_karatsuba_sqr_uint32 () aLen a tmp res =
bn_karatsuba_sqr_open bn_karatsuba_sqr_uint32 aLen a tmp res | val bn_karatsuba_sqr_uint32 : unit -> bn_karatsuba_sqr_st U32
let rec bn_karatsuba_sqr_uint32 () aLen a tmp res = | false | null | false | bn_karatsuba_sqr_open bn_karatsuba_sqr_uint32 aLen a tmp res | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Prims.unit",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Prims.op_LessThan",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_open",
"Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_uint32"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res
inline_for_extraction noextract
val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_ #t =
match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 ()
//TODO: pass tmp as a parameter?
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b))
let bn_karatsuba_mul #t aLen a b res =
push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_mul_ aLen a b tmp res;
pop_frame ()
inline_for_extraction noextract
val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last_sqr #t aLen tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c3 = bn_sub_eq_len_u aLen t01 t23 t45 in
let c5 = c2 -. c3 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t /\ 0 < v len}
-> a:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr_ (v len) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr_open: #t:limb_t -> (self: unit -> bn_karatsuba_sqr_st t) -> bn_karatsuba_sqr_st t
let bn_karatsuba_sqr_open #t (self: unit -> bn_karatsuba_sqr_st t) len a tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_sqr_]]
(K.bn_karatsuba_sqr_ (v len) (as_seq h0 a));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_sqr_u len a res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let t0 = sub tmp 0ul len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
LowStar.Ignore.ignore c0;
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 tmp1 r01;
self () len2 a1 tmp1 r23;
let c = bn_karatsuba_last_sqr len tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_sqr_uint32 : unit -> bn_karatsuba_sqr_st U32 | false | true | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_sqr_uint32 : unit -> bn_karatsuba_sqr_st U32 | [
"recursion"
] | Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_uint32 | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit -> Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_st Lib.IntTypes.U32 | {
"end_col": 62,
"end_line": 375,
"start_col": 2,
"start_line": 375
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_sqr_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t /\ 0 < v len}
-> a:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr_ (v len) (as_seq h0 a)) | let bn_karatsuba_sqr_st (t: limb_t) = | false | null | false |
len: size_t{4 * v len <= max_size_t /\ 0 < v len} ->
a: lbignum t len ->
tmp: lbignum t (4ul *! len) ->
res: lbignum t (len +! len)
-> Stack unit
(requires
fun h ->
live h a /\ live h res /\ live h tmp /\ disjoint res tmp /\ disjoint tmp a /\
disjoint res a)
(ensures
fun h0 _ h1 ->
modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr_ (v len) (as_seq h0 a)) | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Prims.op_LessThan",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Addition",
"Prims.int",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res
inline_for_extraction noextract
val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_ #t =
match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 ()
//TODO: pass tmp as a parameter?
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b))
let bn_karatsuba_mul #t aLen a b res =
push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_mul_ aLen a b tmp res;
pop_frame ()
inline_for_extraction noextract
val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last_sqr #t aLen tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c3 = bn_sub_eq_len_u aLen t01 t23 t45 in
let c5 = c2 -. c3 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
inline_for_extraction noextract | false | true | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_sqr_st : t: Hacl.Bignum.Definitions.limb_t -> Type0 | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_st | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> Type0 | {
"end_col": 63,
"end_line": 338,
"start_col": 4,
"start_line": 329
} |
|
FStar.HyperStack.ST.Stack | val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r) | val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i = | true | null | false | let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0
a
i
(aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r) | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Hacl.Impl.Lib.update_sub_f_carry",
"Hacl.Spec.Bignum.Base.carry",
"Lib.IntTypes.op_Subtraction_Bang",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Spec.Bignum.Addition.bn_add1",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Pervasives.Native.tuple2",
"FStar.Seq.Properties.lseq",
"Prims.unit",
"Hacl.Bignum.Addition.bn_add1",
"FStar.HyperStack.ST.get",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.sub",
"Lib.Buffer.sub"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i)) | false | false | Hacl.Bignum.Karatsuba.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i)) | [] | Hacl.Bignum.Karatsuba.bn_lshift_add_in_place | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Hacl.Bignum.Definitions.lbignum t aLen ->
b1: Hacl.Bignum.Definitions.limb t ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i + 1 <= Lib.IntTypes.v aLen}
-> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry t) | {
"end_col": 39,
"end_line": 99,
"start_col": 44,
"start_line": 94
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b)) | let bn_karatsuba_mul_st (t: limb_t) = | false | null | false |
len: size_t{4 * v len <= max_size_t} ->
a: lbignum t len ->
b: lbignum t len ->
tmp: lbignum t (4ul *! len) ->
res: lbignum t (len +! len)
-> Stack unit
(requires
fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\ disjoint res tmp /\ disjoint tmp a /\
disjoint tmp b /\ disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures
fun h0 _ h1 ->
modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b)) | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.disjoint",
"Lib.Buffer.eq_or_disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Hacl.Spec.Bignum.Definitions.limb",
"Prims.op_Addition",
"Prims.int",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract | false | true | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_mul_st : t: Hacl.Bignum.Definitions.limb_t -> Type0 | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_mul_st | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Bignum.Definitions.limb_t -> Type0 | {
"end_col": 77,
"end_line": 209,
"start_col": 4,
"start_line": 198
} |
|
FStar.HyperStack.ST.Stack | val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c | val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i = | true | null | false | let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0
a
i
bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r)
in
c | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Impl.Lib.update_sub_f_carry",
"Hacl.Bignum.Definitions.limb",
"FStar.Monotonic.HyperStack.mem",
"Hacl.Spec.Bignum.Addition.bn_add",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Pervasives.Native.tuple2",
"FStar.Seq.Properties.lseq",
"Prims.unit",
"Hacl.Bignum.Addition.bn_add_eq_len_u",
"FStar.HyperStack.ST.get",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.sub"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i)) | false | false | Hacl.Bignum.Karatsuba.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i)) | [] | Hacl.Bignum.Karatsuba.bn_lshift_add_early_stop_in_place | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Hacl.Bignum.Definitions.lbignum t aLen ->
b: Hacl.Bignum.Definitions.lbignum t bLen ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i + Lib.IntTypes.v bLen <= Lib.IntTypes.v aLen}
-> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry t) | {
"end_col": 3,
"end_line": 122,
"start_col": 60,
"start_line": 115
} |
FStar.HyperStack.ST.Stack | val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0 | val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res = | true | null | false | let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0 | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Base.carry",
"Prims.unit",
"LowStar.Ignore.ignore",
"Lib.Buffer.map2T",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Base.mask_select",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint",
"Hacl.Bignum.Addition.bn_sub_eq_len_u"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b)) | false | false | Hacl.Bignum.Karatsuba.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b)) | [] | Hacl.Bignum.Karatsuba.bn_sign_abs | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Hacl.Bignum.Definitions.lbignum t aLen ->
b: Hacl.Bignum.Definitions.lbignum t aLen ->
tmp: Hacl.Bignum.Definitions.lbignum t aLen ->
res: Hacl.Bignum.Definitions.lbignum t aLen
-> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry t) | {
"end_col": 4,
"end_line": 51,
"start_col": 38,
"start_line": 46
} |
FStar.HyperStack.ST.Stack | val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3 | val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res = | true | null | false | let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in
let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in
let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3 | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Base.mask_select",
"Hacl.Bignum.Definitions.limb",
"Prims.unit",
"Lib.Buffer.map2T",
"Lib.Buffer.MUT",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.uint",
"Lib.IntTypes.op_Plus_Dot",
"Hacl.Bignum.Addition.bn_add_eq_len_u",
"Hacl.Bignum.Addition.bn_sub_eq_len_u",
"Lib.IntTypes.op_Hat_Dot"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23)) | false | false | Hacl.Bignum.Karatsuba.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23)) | [] | Hacl.Bignum.Karatsuba.bn_middle_karatsuba | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
c0: Hacl.Spec.Bignum.Base.carry t ->
c1: Hacl.Spec.Bignum.Base.carry t ->
c2: Hacl.Spec.Bignum.Base.carry t ->
t01: Hacl.Bignum.Definitions.lbignum t aLen ->
t23: Hacl.Bignum.Definitions.lbignum t aLen ->
tmp: Hacl.Bignum.Definitions.lbignum t aLen ->
res: Hacl.Bignum.Definitions.lbignum t aLen
-> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t) | {
"end_col": 24,
"end_line": 79,
"start_col": 59,
"start_line": 73
} |
FStar.HyperStack.ST.Stack | val bn_karatsuba_sqr:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr (as_seq h0 a)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_sqr #t aLen a res =
push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_sqr_ aLen a tmp res;
pop_frame () | val bn_karatsuba_sqr:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr (as_seq h0 a))
let bn_karatsuba_sqr #t aLen a res = | true | null | false | push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_sqr_ aLen a tmp res;
pop_frame () | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res
inline_for_extraction noextract
val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_ #t =
match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 ()
//TODO: pass tmp as a parameter?
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b))
let bn_karatsuba_mul #t aLen a b res =
push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_mul_ aLen a b tmp res;
pop_frame ()
inline_for_extraction noextract
val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last_sqr #t aLen tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c3 = bn_sub_eq_len_u aLen t01 t23 t45 in
let c5 = c2 -. c3 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t /\ 0 < v len}
-> a:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr_ (v len) (as_seq h0 a))
inline_for_extraction noextract
val bn_karatsuba_sqr_open: #t:limb_t -> (self: unit -> bn_karatsuba_sqr_st t) -> bn_karatsuba_sqr_st t
let bn_karatsuba_sqr_open #t (self: unit -> bn_karatsuba_sqr_st t) len a tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_sqr_]]
(K.bn_karatsuba_sqr_ (v len) (as_seq h0 a));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_sqr_u len a res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let t0 = sub tmp 0ul len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
LowStar.Ignore.ignore c0;
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 tmp1 r01;
self () len2 a1 tmp1 r23;
let c = bn_karatsuba_last_sqr len tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_sqr_uint32 : unit -> bn_karatsuba_sqr_st U32
let rec bn_karatsuba_sqr_uint32 () aLen a tmp res =
bn_karatsuba_sqr_open bn_karatsuba_sqr_uint32 aLen a tmp res
val bn_karatsuba_sqr_uint64 : unit -> bn_karatsuba_sqr_st U64
let rec bn_karatsuba_sqr_uint64 () aLen a tmp res =
bn_karatsuba_sqr_open bn_karatsuba_sqr_uint64 aLen a tmp res
inline_for_extraction noextract
val bn_karatsuba_sqr_: #t:limb_t -> bn_karatsuba_sqr_st t
let bn_karatsuba_sqr_ #t =
match t with
| U32 -> bn_karatsuba_sqr_uint32 ()
| U64 -> bn_karatsuba_sqr_uint64 ()
//TODO: pass tmp as a parameter?
inline_for_extraction noextract
val bn_karatsuba_sqr:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr (as_seq h0 a)) | false | false | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_sqr:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h -> live h a /\ live h res /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr (as_seq h0 a)) | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_sqr | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
aLen:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v aLen /\ 4 * Lib.IntTypes.v aLen <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t aLen ->
res: Hacl.Bignum.Definitions.lbignum t (aLen +! aLen)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 407,
"start_col": 2,
"start_line": 404
} |
FStar.HyperStack.ST.Stack | val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8 | val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res = | true | null | false | let aLen2 = aLen /. 2ul in
[@@ inline_let ]let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8 | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Prims.op_LessThan",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.Karatsuba.bn_lshift_add_in_place",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Hacl.Bignum.Karatsuba.bn_lshift_add_early_stop_in_place",
"Lib.IntTypes.op_Slash_Dot",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45)) | false | false | Hacl.Bignum.Karatsuba.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45)) | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_res | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
r01: Hacl.Bignum.Definitions.lbignum t aLen ->
r23: Hacl.Bignum.Definitions.lbignum t aLen ->
c5: Hacl.Bignum.Definitions.limb t ->
t45: Hacl.Bignum.Definitions.lbignum t aLen ->
res: Hacl.Bignum.Definitions.lbignum t (aLen +! aLen)
-> FStar.HyperStack.ST.Stack (Hacl.Spec.Bignum.Base.carry t) | {
"end_col": 4,
"end_line": 147,
"start_col": 50,
"start_line": 141
} |
FStar.HyperStack.ST.Stack | val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b)) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_mul #t aLen a b res =
push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_mul_ aLen a b tmp res;
pop_frame () | val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b))
let bn_karatsuba_mul #t aLen a b res = | true | null | false | push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_mul_ aLen a b tmp res;
pop_frame () | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Bignum.Karatsuba.bn_karatsuba_mul_",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res
inline_for_extraction noextract
val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_ #t =
match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 ()
//TODO: pass tmp as a parameter?
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b)) | false | false | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b)) | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_mul | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
aLen:
Lib.IntTypes.size_t
{0 < Lib.IntTypes.v aLen /\ 4 * Lib.IntTypes.v aLen <= Lib.IntTypes.max_size_t} ->
a: Hacl.Bignum.Definitions.lbignum t aLen ->
b: Hacl.Bignum.Definitions.lbignum t aLen ->
res: Hacl.Bignum.Definitions.lbignum t (aLen +! aLen)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 289,
"start_col": 2,
"start_line": 286
} |
FStar.HyperStack.ST.Stack | val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres))) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_last_sqr #t aLen tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c3 = bn_sub_eq_len_u aLen t01 t23 t45 in
let c5 = c2 -. c3 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c | val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last_sqr #t aLen tmp res = | true | null | false | let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
let h = ST.get () in
LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c3 = bn_sub_eq_len_u aLen t01 t23 t45 in
let c5 = c2 -. c3 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_LessThan",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.Karatsuba.bn_karatsuba_res",
"Lib.IntTypes.int_t",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Subtraction_Dot",
"Hacl.Bignum.Addition.bn_sub_eq_len_u",
"Hacl.Bignum.Addition.bn_add_eq_len_u",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.sub",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Prims.op_Addition",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.append",
"Lib.Buffer.as_seq",
"Lib.Sequence.concat",
"Lib.Sequence.lemma_concat2",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res
inline_for_extraction noextract
val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_ #t =
match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 ()
//TODO: pass tmp as a parameter?
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b))
let bn_karatsuba_mul #t aLen a b res =
push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_mul_ aLen a b tmp res;
pop_frame ()
inline_for_extraction noextract
val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres))) | false | false | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres))) | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_last_sqr | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
aLen:
Lib.IntTypes.size_t
{ 4 * Lib.IntTypes.v aLen <= Lib.IntTypes.max_size_t /\ Lib.IntTypes.v aLen % 2 = 0 /\
0 < Lib.IntTypes.v aLen } ->
tmp: Hacl.Bignum.Definitions.lbignum t (4ul *! aLen) ->
res: Hacl.Bignum.Definitions.lbignum t (aLen +! aLen)
-> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t) | {
"end_col": 3,
"end_line": 324,
"start_col": 43,
"start_line": 309
} |
FStar.HyperStack.ST.Stack | val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres))) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c | val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res = | true | null | false | let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
let h = ST.get () in
LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Prims.op_Equality",
"Prims.int",
"Prims.op_Modulus",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.Karatsuba.bn_karatsuba_res",
"Hacl.Bignum.Karatsuba.bn_middle_karatsuba",
"Hacl.Bignum.Addition.bn_add_eq_len_u",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.sub",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Prims.op_Addition",
"FStar.Seq.Base.seq",
"Lib.Sequence.to_seq",
"FStar.Seq.Base.append",
"Lib.Buffer.as_seq",
"Lib.Sequence.concat",
"Lib.Sequence.lemma_concat2",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres))) | false | false | Hacl.Bignum.Karatsuba.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres))) | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_last | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
aLen:
Lib.IntTypes.size_t
{ 4 * Lib.IntTypes.v aLen <= Lib.IntTypes.max_size_t /\ Lib.IntTypes.v aLen % 2 = 0 /\
0 < Lib.IntTypes.v aLen } ->
c0: Hacl.Spec.Bignum.Base.carry t ->
c1: Hacl.Spec.Bignum.Base.carry t ->
tmp: Hacl.Bignum.Definitions.lbignum t (4ul *! aLen) ->
res: Hacl.Bignum.Definitions.lbignum t (aLen +! aLen)
-> FStar.HyperStack.ST.Stack (Hacl.Bignum.Definitions.limb t) | {
"end_col": 3,
"end_line": 184,
"start_col": 45,
"start_line": 169
} |
Prims.Tot | val bn_karatsuba_sqr_open: #t:limb_t -> (self: unit -> bn_karatsuba_sqr_st t) -> bn_karatsuba_sqr_st t | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_sqr_open #t (self: unit -> bn_karatsuba_sqr_st t) len a tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_sqr_]]
(K.bn_karatsuba_sqr_ (v len) (as_seq h0 a));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_sqr_u len a res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let t0 = sub tmp 0ul len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
LowStar.Ignore.ignore c0;
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 tmp1 r01;
self () len2 a1 tmp1 r23;
let c = bn_karatsuba_last_sqr len tmp res in
LowStar.Ignore.ignore c;
() end | val bn_karatsuba_sqr_open: #t:limb_t -> (self: unit -> bn_karatsuba_sqr_st t) -> bn_karatsuba_sqr_st t
let bn_karatsuba_sqr_open #t (self: (unit -> bn_karatsuba_sqr_st t)) len a tmp res = | false | null | false | let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_sqr_]]
(K.bn_karatsuba_sqr_ (v len) (as_seq h0 a));
if len <. bn_mul_threshold || len %. 2ul =. 1ul
then bn_sqr_u len a res
else
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let t0 = sub tmp 0ul len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
LowStar.Ignore.ignore c0;
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 tmp1 r01;
self () len2 a1 tmp1 r23;
let c = bn_karatsuba_last_sqr len tmp res in
LowStar.Ignore.ignore c;
() | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Prims.unit",
"Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_st",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Prims.op_LessThan",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Prims.op_BarBar",
"Lib.IntTypes.op_Less_Dot",
"Hacl.Bignum.Karatsuba.bn_mul_threshold",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.op_Percent_Dot",
"Hacl.Bignum.Multiplication.bn_sqr_u",
"Prims.bool",
"LowStar.Ignore.ignore",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.Karatsuba.bn_karatsuba_last_sqr",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.sub",
"Lib.IntTypes.add",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.Karatsuba.bn_sign_abs",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Slash_Dot",
"FStar.Pervasives.norm_spec",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"FStar.Pervasives.primops",
"FStar.Pervasives.delta_only",
"Prims.string",
"Prims.Nil",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_Addition",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_sqr_",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract
val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end
val bn_karatsuba_mul_uint32 : unit -> bn_karatsuba_mul_st U32
let rec bn_karatsuba_mul_uint32 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint32 aLen a b tmp res
val bn_karatsuba_mul_uint64 : unit -> bn_karatsuba_mul_st U64
let rec bn_karatsuba_mul_uint64 () aLen a b tmp res =
bn_karatsuba_mul_open bn_karatsuba_mul_uint64 aLen a b tmp res
inline_for_extraction noextract
val bn_karatsuba_mul_: #t:limb_t -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_ #t =
match t with
| U32 -> bn_karatsuba_mul_uint32 ()
| U64 -> bn_karatsuba_mul_uint64 ()
//TODO: pass tmp as a parameter?
inline_for_extraction noextract
val bn_karatsuba_mul:
#t:limb_t
-> aLen:size_t{0 < v aLen /\ 4 * v aLen <= max_size_t}
-> a:lbignum t aLen
-> b:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul (as_seq h0 a) (as_seq h0 b))
let bn_karatsuba_mul #t aLen a b res =
push_frame ();
let tmp = create (4ul *! aLen) (uint #t 0) in
bn_karatsuba_mul_ aLen a b tmp res;
pop_frame ()
inline_for_extraction noextract
val bn_karatsuba_last_sqr:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba_sqr sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last_sqr #t aLen tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c3 = bn_sub_eq_len_u aLen t01 t23 t45 in
let c5 = c2 -. c3 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
inline_for_extraction noextract
let bn_karatsuba_sqr_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t /\ 0 < v len}
-> a:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint res a)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_sqr_ (v len) (as_seq h0 a))
inline_for_extraction noextract | false | false | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_sqr_open: #t:limb_t -> (self: unit -> bn_karatsuba_sqr_st t) -> bn_karatsuba_sqr_st t | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_open | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | self: (self: Prims.unit -> Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_st t)
-> Hacl.Bignum.Karatsuba.bn_karatsuba_sqr_st t | {
"end_col": 10,
"end_line": 370,
"start_col": 82,
"start_line": 343
} |
Prims.Tot | val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Karatsuba",
"short_module": "K"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Multiplication",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Addition",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Lib",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_karatsuba_mul_open #t (self: unit -> bn_karatsuba_mul_st t) len a b tmp res =
let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul then
bn_mul_u len a len b res
else begin
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
// tmp = [ t0_len2; t1_len2; ..]
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
// tmp = [ t0_len2; t1_len2; t23_len; ..]
(**) let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() end | val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t
let bn_karatsuba_mul_open #t (self: (unit -> bn_karatsuba_mul_st t)) len a b tmp res = | false | null | false | let h0 = ST.get () in
norm_spec [zeta; iota; primops; delta_only [`%K.bn_karatsuba_mul_]]
(K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b));
if len <. bn_mul_threshold || len %. 2ul =. 1ul
then bn_mul_u len a len b res
else
let len2 = len /. 2ul in
let a0 = sub a 0ul len2 in
let a1 = sub a len2 len2 in
let b0 = sub b 0ul len2 in
let b1 = sub b len2 len2 in
let t0 = sub tmp 0ul len2 in
let t1 = sub tmp len2 len2 in
let tmp' = sub tmp len len2 in
let c0 = bn_sign_abs a0 a1 tmp' t0 in
let c1 = bn_sign_abs b0 b1 tmp' t1 in
let h0 = ST.get () in
let t23 = sub tmp len len in
let tmp1 = sub tmp (len +! len) (len +! len) in
self () len2 t0 t1 tmp1 t23;
let r01 = sub res 0ul len in
let r23 = sub res len len in
self () len2 a0 b0 tmp1 r01;
self () len2 a1 b1 tmp1 r23;
let c = bn_karatsuba_last len c0 c1 tmp res in
LowStar.Ignore.ignore c;
() | {
"checked_file": "Hacl.Bignum.Karatsuba.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.Karatsuba.fst.checked",
"Hacl.Spec.Bignum.Addition.fst.checked",
"Hacl.Impl.Lib.fst.checked",
"Hacl.Bignum.Multiplication.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Base.fst.checked",
"Hacl.Bignum.Addition.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.Karatsuba.fst"
} | [
"total"
] | [
"Hacl.Bignum.Definitions.limb_t",
"Prims.unit",
"Hacl.Bignum.Karatsuba.bn_karatsuba_mul_st",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.op_Plus_Bang",
"Prims.op_BarBar",
"Lib.IntTypes.op_Less_Dot",
"Hacl.Bignum.Karatsuba.bn_mul_threshold",
"Lib.IntTypes.op_Equals_Dot",
"Lib.IntTypes.op_Percent_Dot",
"Hacl.Bignum.Multiplication.bn_mul_u",
"Prims.bool",
"LowStar.Ignore.ignore",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.Karatsuba.bn_karatsuba_last",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.Buffer.sub",
"Lib.IntTypes.add",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.Spec.Bignum.Base.carry",
"Hacl.Bignum.Karatsuba.bn_sign_abs",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Slash_Dot",
"FStar.Pervasives.norm_spec",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"FStar.Pervasives.primops",
"FStar.Pervasives.delta_only",
"Prims.string",
"Prims.Nil",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.op_Addition",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.Buffer.as_seq",
"Hacl.Spec.Bignum.Karatsuba.bn_karatsuba_mul_"
] | [] | module Hacl.Bignum.Karatsuba
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
open Hacl.Bignum.Base
open Hacl.Impl.Lib
open Hacl.Bignum.Addition
open Hacl.Bignum.Multiplication
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module B = LowStar.Buffer
module Loops = Lib.LoopCombinators
module K = Hacl.Spec.Bignum.Karatsuba
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_mul_threshold = size K.bn_mul_threshold
inline_for_extraction noextract
val bn_sign_abs:
#t:limb_t
-> #aLen:size_t
-> a:lbignum t aLen
-> b:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (carry t)
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
eq_or_disjoint a b /\ disjoint a res /\ disjoint b res /\
disjoint a tmp /\ disjoint b tmp /\ disjoint tmp res)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(c, as_seq h1 res) == K.bn_sign_abs (as_seq h0 a) (as_seq h0 b))
let bn_sign_abs #t #aLen a b tmp res =
let c0 = bn_sub_eq_len_u aLen a b tmp in
let c1 = bn_sub_eq_len_u aLen b a res in
map2T aLen res (mask_select (uint #t 0 -. c0)) res tmp;
LowStar.Ignore.ignore c1;
c0
inline_for_extraction noextract
val bn_middle_karatsuba:
#t:limb_t
-> #aLen:size_t
-> c0:carry t
-> c1:carry t
-> c2:carry t
-> t01:lbignum t aLen
-> t23:lbignum t aLen
-> tmp:lbignum t aLen
-> res:lbignum t aLen ->
Stack (limb t)
(requires fun h ->
live h t01 /\ live h t23 /\ live h tmp /\ live h res /\
disjoint t01 t23 /\ disjoint tmp res /\ disjoint t01 res /\
disjoint t01 tmp /\ disjoint t23 tmp /\ disjoint t23 res)
(ensures fun h0 c h1 -> modifies (loc tmp |+| loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_middle_karatsuba c0 c1 c2 (as_seq h0 t01) (as_seq h0 t23))
let bn_middle_karatsuba #t #aLen c0 c1 c2 t01 t23 tmp res =
let c_sign = c0 ^. c1 in
let c3 = bn_sub_eq_len_u aLen t01 t23 tmp in let c3 = c2 -. c3 in
let c4 = bn_add_eq_len_u aLen t01 t23 res in let c4 = c2 +. c4 in
let mask = uint #t 0 -. c_sign in
map2T aLen res (mask_select mask) res tmp;
mask_select mask c4 c3
inline_for_extraction noextract
val bn_lshift_add_in_place:
#t:limb_t
-> #aLen:size_t{0 < v aLen}
-> a:lbignum t aLen
-> b1:limb t
-> i:size_t{v i + 1 <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add (as_seq h0 a) b1 (v i))
let bn_lshift_add_in_place #t #aLen a b1 i =
let r = sub a i (aLen -! i) in
let h0 = ST.get () in
update_sub_f_carry h0 a i (aLen -! i)
(fun h -> Hacl.Spec.Bignum.Addition.bn_add1 (as_seq h0 r) b1)
(fun _ -> bn_add1 (aLen -! i) r b1 r)
inline_for_extraction noextract
val bn_lshift_add_early_stop_in_place:
#t:limb_t
-> #aLen:size_t
-> #bLen:size_t
-> a:lbignum t aLen
-> b:lbignum t bLen
-> i:size_t{v i + v bLen <= v aLen} ->
Stack (carry t)
(requires fun h -> live h a /\ live h b /\ disjoint a b)
(ensures fun h0 c h1 -> modifies (loc a) h0 h1 /\
(c, as_seq h1 a) == K.bn_lshift_add_early_stop (as_seq h0 a) (as_seq h0 b) (v i))
let bn_lshift_add_early_stop_in_place #t #aLen #bLen a b i =
let r = sub a i bLen in
let h0 = ST.get () in
let c =
update_sub_f_carry h0 a i bLen
(fun h -> Hacl.Spec.Bignum.Addition.bn_add (as_seq h0 r) (as_seq h0 b))
(fun _ -> bn_add_eq_len_u bLen r b r) in
c
inline_for_extraction noextract
val bn_karatsuba_res:
#t:limb_t
-> #aLen:size_t{2 * v aLen <= max_size_t /\ 0 < v aLen}
-> r01:lbignum t aLen
-> r23:lbignum t aLen
-> c5:limb t
-> t45:lbignum t aLen
-> res:lbignum t (aLen +! aLen) ->
Stack (carry t)
(requires fun h ->
live h r01 /\ live h r23 /\ live h t45 /\ live h res /\ disjoint t45 res /\
as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23))
(ensures fun h0 c h1 -> modifies (loc res) h0 h1 /\
(c, as_seq h1 res) == K.bn_karatsuba_res (as_seq h0 r01) (as_seq h0 r23) c5 (as_seq h0 t45))
let bn_karatsuba_res #t #aLen r01 r23 c5 t45 res =
let aLen2 = aLen /. 2ul in
[@inline_let] let resLen = aLen +! aLen in
let c6 = bn_lshift_add_early_stop_in_place res t45 aLen2 in
let c7 = c5 +. c6 in
let c8 = bn_lshift_add_in_place res c7 (aLen +! aLen2) in
c8
inline_for_extraction noextract
val bn_karatsuba_last:
#t:limb_t
-> aLen:size_t{4 * v aLen <= max_size_t /\ v aLen % 2 = 0 /\ 0 < v aLen}
-> c0:carry t
-> c1:carry t
-> tmp:lbignum t (4ul *! aLen)
-> res:lbignum t (aLen +! aLen) ->
Stack (limb t)
(requires fun h -> live h res /\ live h tmp /\ disjoint res tmp)
(ensures fun h0 c h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
(let sr01 = LSeq.sub (as_seq h0 res) 0 (v aLen) in
let sr23 = LSeq.sub (as_seq h0 res) (v aLen) (v aLen) in
let st23 = LSeq.sub (as_seq h0 tmp) (v aLen) (v aLen) in
let sc2, st01 = Hacl.Spec.Bignum.Addition.bn_add sr01 sr23 in
let sc5, sres = K.bn_middle_karatsuba c0 c1 sc2 st01 st23 in
let sc, sres = K.bn_karatsuba_res sr01 sr23 sc5 sres in
(c, as_seq h1 res) == (sc, sres)))
let bn_karatsuba_last #t aLen c0 c1 tmp res =
let r01 = sub res 0ul aLen in
let r23 = sub res aLen aLen in
(**) let h = ST.get () in
(**) LSeq.lemma_concat2 (v aLen) (as_seq h r01) (v aLen) (as_seq h r23) (as_seq h res);
(**) assert (as_seq h res == LSeq.concat (as_seq h r01) (as_seq h r23));
let t01 = sub tmp 0ul aLen in
let t23 = sub tmp aLen aLen in
let t45 = sub tmp (2ul *! aLen) aLen in
let t67 = sub tmp (3ul *! aLen) aLen in
let c2 = bn_add_eq_len_u aLen r01 r23 t01 in
let c5 = bn_middle_karatsuba c0 c1 c2 t01 t23 t67 t45 in
let c = bn_karatsuba_res r01 r23 c5 t45 res in
c
#push-options "--z3rlimit 150"
(* from Jonathan:
let karatsuba_t = dst:bignum -> a:bignum -> b:bignum -> Stack unit ensures dst = a * b
inline_for_extraction
let karatsuba_open (self: unit -> karastuba_t): fun dst a b ->
... self () dst' a' b' ...
let rec karatsuba () = karatsuba_open karastuba
*)
inline_for_extraction noextract
let bn_karatsuba_mul_st (t:limb_t) =
len:size_t{4 * v len <= max_size_t}
-> a:lbignum t len
-> b:lbignum t len
-> tmp:lbignum t (4ul *! len)
-> res:lbignum t (len +! len) ->
Stack unit
(requires fun h ->
live h a /\ live h b /\ live h res /\ live h tmp /\
disjoint res tmp /\ disjoint tmp a /\ disjoint tmp b /\
disjoint res a /\ disjoint res b /\ eq_or_disjoint a b)
(ensures fun h0 _ h1 -> modifies (loc res |+| loc tmp) h0 h1 /\
as_seq h1 res == K.bn_karatsuba_mul_ (v len) (as_seq h0 a) (as_seq h0 b))
inline_for_extraction noextract | false | false | Hacl.Bignum.Karatsuba.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": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_karatsuba_mul_open: #t:limb_t -> (self: unit -> bn_karatsuba_mul_st t) -> bn_karatsuba_mul_st t | [] | Hacl.Bignum.Karatsuba.bn_karatsuba_mul_open | {
"file_name": "code/bignum/Hacl.Bignum.Karatsuba.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | self: (self: Prims.unit -> Hacl.Bignum.Karatsuba.bn_karatsuba_mul_st t)
-> Hacl.Bignum.Karatsuba.bn_karatsuba_mul_st t | {
"end_col": 10,
"end_line": 249,
"start_col": 84,
"start_line": 214
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_string e =
is_some (destruct_string e) | let is_string e = | false | null | false | is_some (destruct_string e) | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"Test.Lowstarize.is_some",
"Prims.string",
"Test.Lowstarize.destruct_string",
"Prims.bool"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract | false | true | Test.Lowstarize.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 is_string : e: FStar.Reflection.Types.term -> Prims.bool | [] | Test.Lowstarize.is_string | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | e: FStar.Reflection.Types.term -> Prims.bool | {
"end_col": 29,
"end_line": 54,
"start_col": 2,
"start_line": 54
} |
|
FStar.Tactics.Effect.Tac | val mk_uint32 (x: int) : Tac term | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit)) | val mk_uint32 (x: int) : Tac term
let mk_uint32 (x: int) : Tac term = | true | null | false | pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar"; "UInt32"; "__uint_to_t"]))) (mk_int x, Q_Explicit)) | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"Prims.int",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Data.term_view",
"FStar.Reflection.V1.Data.Tv_App",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.aqualv",
"Test.Lowstarize.mk_int",
"FStar.Reflection.V1.Data.Q_Explicit",
"FStar.Reflection.V1.Data.Tv_FVar",
"FStar.Reflection.V1.Builtins.pack_fv",
"Prims.Cons",
"Prims.string",
"Prims.Nil"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract | false | false | Test.Lowstarize.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 mk_uint32 (x: int) : Tac term | [] | Test.Lowstarize.mk_uint32 | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Prims.int -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 27,
"end_line": 29,
"start_col": 2,
"start_line": 28
} |
FStar.Tactics.Effect.Tac | val mk_uint8 (x: int) : Tac term | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit)) | val mk_uint8 (x: int) : Tac term
let mk_uint8 (x: int) : Tac term = | true | null | false | pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar"; "UInt8"; "__uint_to_t"]))) (mk_int x, Q_Explicit)) | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"Prims.int",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Data.term_view",
"FStar.Reflection.V1.Data.Tv_App",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.aqualv",
"Test.Lowstarize.mk_int",
"FStar.Reflection.V1.Data.Q_Explicit",
"FStar.Reflection.V1.Data.Tv_FVar",
"FStar.Reflection.V1.Builtins.pack_fv",
"Prims.Cons",
"Prims.string",
"Prims.Nil"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract | false | false | Test.Lowstarize.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 mk_uint8 (x: int) : Tac term | [] | Test.Lowstarize.mk_uint8 | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: Prims.int -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 27,
"end_line": 24,
"start_col": 2,
"start_line": 23
} |
FStar.Tactics.Effect.Tac | val lowstarize_string (s: string) : Tac term | [
{
"abbrev": true,
"full_module": "C.String",
"short_module": "Whatever"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lowstarize_string (s: string): Tac term =
`(C.String.of_literal (`@s)) | val lowstarize_string (s: string) : Tac term
let lowstarize_string (s: string) : Tac term = | true | null | false | `(C.String.of_literal (`@s)) | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"Prims.string",
"FStar.Reflection.Types.term"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract
let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ]
noextract
let destruct_tuple (e: term): option (list term) =
let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns then
Some (List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> []
) args)
else
None
| _ ->
None
noextract
let is_tuple (e: term) =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
List.Tot.contains (inspect_fv fv) mktuple_qns
| _ ->
false
noextract
let destruct_hex (e: term) =
let hd, tl = collect_app e in
if term_eq (`h) hd && List.Tot.length tl > 0 then begin
destruct_string (fst (List.Tot.hd tl))
end else
None
noextract
let is_hex e =
is_some (destruct_hex e)
// Main Tactic. This tactic fetches a top-level term and defines another,
// Low*-ized top-level term for it, where:
// - hex-encoded strings are lifted as top-level constant uint8 arrays
// - references to hex-encoded strings are replaced by a pair of the length
// of the corresponding array, and a reference to that array
// - lists are lifted as top-level arrays (using gcmalloc_of_list)
// - strings that are not marked as hex-encoded are lifted to C.String.t
// - tuples are traversed transparently
// - everything else is left as-is
//
// TODO: instead of pairs, use a dependent type that ties together an array and
// its length
let gensym = string * nat
noextract
let fresh (uniq: gensym): Tac (gensym * name) =
(fst uniq, snd uniq + 1), cur_module () @ [ fst uniq ^ string_of_int (snd uniq) ]
noeq
type lbuffer (a:Type0) =
| LB: len:UInt32.t -> b:B.buffer a{B.len b == len /\ B.recallable b} -> lbuffer a
noextract
let mk_gcmalloc_of_list (uniq: gensym) (arg: term) (l:int) (t: option term):
Tac (gensym * sigelt * term)
=
let def: term = pack (Tv_App
(pack (Tv_App (`LowStar.Buffer.gcmalloc_of_list) (`HS.root, Q_Explicit)))
(arg, Q_Explicit)
) in
let uniq, name = fresh uniq in
let fv: fv = pack_fv name in
let t: term = match t with None -> pack Tv_Unknown | Some t -> t in
let lb = pack_lb ({lb_fv = fv;
lb_us = [];
lb_typ = t;
lb_def = def}) in
let se: sigelt = pack_sigelt (Sg_Let false [lb]) in
uniq, se, mk_e_app (`LB) [mk_uint32 l; pack (Tv_FVar fv)]
noextract
let lowstarize_hex (uniq: gensym) (s: string): Tac (gensym * option sigelt * term) =
if String.length s % 2 <> 0
|| not (List.Tot.for_all is_hex_digit (String.list_of_string s)) then
fail ("Invalid hex string: " ^ s)
else
let constants = as_uint8s [] (String.list_of_string s) in
if String.length s = 0 then
let null = pack (Tv_App (`LowStar.Buffer.null) (`UInt8.t, Q_Implicit)) in
uniq, None, mk_e_app (`LB) [mk_uint32 0; null]
else
let l = normalize_term (String.length s / 2) in
let uniq, se, e = mk_gcmalloc_of_list uniq constants l None in
uniq, Some se, e
// Dependency analysis bug: does not go inside quotations (#1496)
module Whatever = C.String
noextract | false | false | Test.Lowstarize.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 lowstarize_string (s: string) : Tac term | [] | Test.Lowstarize.lowstarize_string | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: Prims.string -> FStar.Tactics.Effect.Tac FStar.Reflection.Types.term | {
"end_col": 30,
"end_line": 195,
"start_col": 2,
"start_line": 195
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None | let destruct_string e = | false | null | false | match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.V1.Builtins.inspect_ln",
"Prims.string",
"FStar.Pervasives.Native.Some",
"FStar.Reflection.V1.Data.term_view",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract | false | true | Test.Lowstarize.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 destruct_string : e: FStar.Reflection.Types.term -> FStar.Pervasives.Native.option Prims.string | [] | Test.Lowstarize.destruct_string | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | e: FStar.Reflection.Types.term -> FStar.Pervasives.Native.option Prims.string | {
"end_col": 13,
"end_line": 47,
"start_col": 2,
"start_line": 45
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ] | let mktuple_qns = | false | null | false | [mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn; mktuple7_qn; mktuple8_qn] | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [
"total"
] | [
"Prims.Cons",
"Prims.list",
"Prims.string",
"FStar.Reflection.Const.mktuple2_qn",
"FStar.Reflection.Const.mktuple3_qn",
"FStar.Reflection.Const.mktuple4_qn",
"FStar.Reflection.Const.mktuple5_qn",
"FStar.Reflection.Const.mktuple6_qn",
"FStar.Reflection.Const.mktuple7_qn",
"FStar.Reflection.Const.mktuple8_qn",
"Prims.Nil"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract | false | true | Test.Lowstarize.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 mktuple_qns : Prims.list (Prims.list Prims.string) | [] | Test.Lowstarize.mktuple_qns | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.list (Prims.list Prims.string) | {
"end_col": 30,
"end_line": 93,
"start_col": 2,
"start_line": 92
} |
|
FStar.Tactics.Effect.Tac | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_hex e =
is_some (destruct_hex e) | let is_hex e = | true | null | false | is_some (destruct_hex e) | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"FStar.Reflection.Types.term",
"Test.Lowstarize.is_some",
"Prims.string",
"Prims.bool",
"FStar.Pervasives.Native.option",
"Test.Lowstarize.destruct_hex"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract
let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ]
noextract
let destruct_tuple (e: term): option (list term) =
let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns then
Some (List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> []
) args)
else
None
| _ ->
None
noextract
let is_tuple (e: term) =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
List.Tot.contains (inspect_fv fv) mktuple_qns
| _ ->
false
noextract
let destruct_hex (e: term) =
let hd, tl = collect_app e in
if term_eq (`h) hd && List.Tot.length tl > 0 then begin
destruct_string (fst (List.Tot.hd tl))
end else
None
noextract | false | false | Test.Lowstarize.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 is_hex : e: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool | [] | Test.Lowstarize.is_hex | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | e: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 26,
"end_line": 131,
"start_col": 2,
"start_line": 131
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gensym = string * nat | let gensym = | false | null | false | string * nat | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.tuple2",
"Prims.string",
"Prims.nat"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract
let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ]
noextract
let destruct_tuple (e: term): option (list term) =
let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns then
Some (List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> []
) args)
else
None
| _ ->
None
noextract
let is_tuple (e: term) =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
List.Tot.contains (inspect_fv fv) mktuple_qns
| _ ->
false
noextract
let destruct_hex (e: term) =
let hd, tl = collect_app e in
if term_eq (`h) hd && List.Tot.length tl > 0 then begin
destruct_string (fst (List.Tot.hd tl))
end else
None
noextract
let is_hex e =
is_some (destruct_hex e)
// Main Tactic. This tactic fetches a top-level term and defines another,
// Low*-ized top-level term for it, where:
// - hex-encoded strings are lifted as top-level constant uint8 arrays
// - references to hex-encoded strings are replaced by a pair of the length
// of the corresponding array, and a reference to that array
// - lists are lifted as top-level arrays (using gcmalloc_of_list)
// - strings that are not marked as hex-encoded are lifted to C.String.t
// - tuples are traversed transparently
// - everything else is left as-is
//
// TODO: instead of pairs, use a dependent type that ties together an array and
// its length | false | true | Test.Lowstarize.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 gensym : Type0 | [] | Test.Lowstarize.gensym | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 25,
"end_line": 146,
"start_col": 13,
"start_line": 146
} |
|
Prims.Tot | val mk_int (i: int) : term | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i)) | val mk_int (i: int) : term
let mk_int (i: int) : term = | false | null | false | pack_ln (Tv_Const (C_Int i)) | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [
"total"
] | [
"Prims.int",
"FStar.Reflection.V1.Builtins.pack_ln",
"FStar.Reflection.V1.Data.Tv_Const",
"FStar.Reflection.V1.Data.C_Int",
"FStar.Reflection.Types.term"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract | false | true | Test.Lowstarize.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 mk_int (i: int) : term | [] | Test.Lowstarize.mk_int | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | i: Prims.int -> FStar.Reflection.Types.term | {
"end_col": 30,
"end_line": 19,
"start_col": 2,
"start_line": 19
} |
Prims.Tot | val destruct_tuple (e: term) : option (list term) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let destruct_tuple (e: term): option (list term) =
let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns then
Some (List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> []
) args)
else
None
| _ ->
None | val destruct_tuple (e: term) : option (list term)
let destruct_tuple (e: term) : option (list term) = | false | null | false | let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns
then
Some
(List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> [])
args)
else None
| _ -> None | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [
"total"
] | [
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Reflection.V1.Data.argv",
"FStar.Reflection.V1.Builtins.inspect_ln",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V1.Data.universes",
"FStar.List.Tot.Base.contains",
"Prims.string",
"FStar.Reflection.V1.Builtins.inspect_fv",
"Test.Lowstarize.mktuple_qns",
"FStar.Pervasives.Native.Some",
"FStar.List.Tot.Base.concatMap",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V1.Data.aqualv",
"Prims.Cons",
"Prims.Nil",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.option",
"FStar.Reflection.V1.Data.term_view",
"FStar.Reflection.V1.Derived.collect_app_ln"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract
let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ] | false | true | Test.Lowstarize.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 destruct_tuple (e: term) : option (list term) | [] | Test.Lowstarize.destruct_tuple | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | e: FStar.Reflection.Types.term
-> FStar.Pervasives.Native.option (Prims.list FStar.Reflection.Types.term) | {
"end_col": 10,
"end_line": 110,
"start_col": 50,
"start_line": 96
} |
FStar.Tactics.Effect.Tac | val must (x: option 'a) : Tac 'a | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must" | val must (x: option 'a) : Tac 'a
let must (x: option 'a) : Tac 'a = | true | null | false | match x with
| Some x -> x
| None -> fail "must" | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"FStar.Pervasives.Native.option",
"FStar.Tactics.V1.Derived.fail"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract | false | false | Test.Lowstarize.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 must (x: option 'a) : Tac 'a | [] | Test.Lowstarize.must | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | x: FStar.Pervasives.Native.option 'a -> FStar.Tactics.Effect.Tac 'a | {
"end_col": 23,
"end_line": 60,
"start_col": 2,
"start_line": 58
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_some = function Some _ -> true | None -> false | let is_some = | false | null | false | function
| Some _ -> true
| None -> false | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.option",
"Prims.bool"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None | false | false | Test.Lowstarize.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 is_some : _: FStar.Pervasives.Native.option _ -> Prims.bool | [] | Test.Lowstarize.is_some | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: FStar.Pervasives.Native.option _ -> Prims.bool | {
"end_col": 53,
"end_line": 50,
"start_col": 14,
"start_line": 50
} |
|
FStar.Tactics.Effect.Tac | val fresh (uniq: gensym) : Tac (gensym * name) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_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 (uniq: gensym): Tac (gensym * name) =
(fst uniq, snd uniq + 1), cur_module () @ [ fst uniq ^ string_of_int (snd uniq) ] | val fresh (uniq: gensym) : Tac (gensym * name)
let fresh (uniq: gensym) : Tac (gensym * name) = | true | null | false | (fst uniq, snd uniq + 1), cur_module () @ [fst uniq ^ string_of_int (snd uniq)] | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"Test.Lowstarize.gensym",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.Types.name",
"Prims.string",
"Prims.nat",
"FStar.Pervasives.Native.fst",
"Prims.op_Addition",
"FStar.Pervasives.Native.snd",
"FStar.Pervasives.Native.tuple2",
"FStar.List.Tot.Base.op_At",
"Prims.Cons",
"Prims.op_Hat",
"Prims.string_of_int",
"Prims.Nil",
"Prims.list",
"FStar.Tactics.V1.Derived.cur_module"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract
let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ]
noextract
let destruct_tuple (e: term): option (list term) =
let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns then
Some (List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> []
) args)
else
None
| _ ->
None
noextract
let is_tuple (e: term) =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
List.Tot.contains (inspect_fv fv) mktuple_qns
| _ ->
false
noextract
let destruct_hex (e: term) =
let hd, tl = collect_app e in
if term_eq (`h) hd && List.Tot.length tl > 0 then begin
destruct_string (fst (List.Tot.hd tl))
end else
None
noextract
let is_hex e =
is_some (destruct_hex e)
// Main Tactic. This tactic fetches a top-level term and defines another,
// Low*-ized top-level term for it, where:
// - hex-encoded strings are lifted as top-level constant uint8 arrays
// - references to hex-encoded strings are replaced by a pair of the length
// of the corresponding array, and a reference to that array
// - lists are lifted as top-level arrays (using gcmalloc_of_list)
// - strings that are not marked as hex-encoded are lifted to C.String.t
// - tuples are traversed transparently
// - everything else is left as-is
//
// TODO: instead of pairs, use a dependent type that ties together an array and
// its length
let gensym = string * nat
noextract | false | false | Test.Lowstarize.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 fresh (uniq: gensym) : Tac (gensym * name) | [] | Test.Lowstarize.fresh | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | uniq: Test.Lowstarize.gensym
-> FStar.Tactics.Effect.Tac (Test.Lowstarize.gensym * FStar.Reflection.Types.name) | {
"end_col": 83,
"end_line": 150,
"start_col": 2,
"start_line": 150
} |
FStar.Tactics.Effect.Tac | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_tuple (e: term) =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
List.Tot.contains (inspect_fv fv) mktuple_qns
| _ ->
false | let is_tuple (e: term) = | true | null | false | match inspect (fst (collect_app e)) with
| Tv_UInst fv _ | Tv_FVar fv -> List.Tot.contains (inspect_fv fv) mktuple_qns
| _ -> false | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V1.Data.universes",
"FStar.List.Tot.Base.contains",
"Prims.list",
"Prims.string",
"FStar.Reflection.V1.Builtins.inspect_fv",
"Test.Lowstarize.mktuple_qns",
"FStar.Reflection.V1.Data.term_view",
"Prims.bool",
"FStar.Tactics.V1.Builtins.inspect",
"FStar.Pervasives.Native.fst",
"FStar.Reflection.V1.Data.argv",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.V1.SyntaxHelpers.collect_app"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract
let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ]
noextract
let destruct_tuple (e: term): option (list term) =
let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns then
Some (List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> []
) args)
else
None
| _ ->
None
noextract | false | false | Test.Lowstarize.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 is_tuple : e: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool | [] | Test.Lowstarize.is_tuple | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | e: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 11,
"end_line": 119,
"start_col": 2,
"start_line": 114
} |
|
FStar.Tactics.Effect.Tac | val lowstarize_hex (uniq: gensym) (s: string) : Tac (gensym * option sigelt * term) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lowstarize_hex (uniq: gensym) (s: string): Tac (gensym * option sigelt * term) =
if String.length s % 2 <> 0
|| not (List.Tot.for_all is_hex_digit (String.list_of_string s)) then
fail ("Invalid hex string: " ^ s)
else
let constants = as_uint8s [] (String.list_of_string s) in
if String.length s = 0 then
let null = pack (Tv_App (`LowStar.Buffer.null) (`UInt8.t, Q_Implicit)) in
uniq, None, mk_e_app (`LB) [mk_uint32 0; null]
else
let l = normalize_term (String.length s / 2) in
let uniq, se, e = mk_gcmalloc_of_list uniq constants l None in
uniq, Some se, e | val lowstarize_hex (uniq: gensym) (s: string) : Tac (gensym * option sigelt * term)
let lowstarize_hex (uniq: gensym) (s: string) : Tac (gensym * option sigelt * term) = | true | null | false | if String.length s % 2 <> 0 || not (List.Tot.for_all is_hex_digit (String.list_of_string s))
then fail ("Invalid hex string: " ^ s)
else
let constants = as_uint8s [] (String.list_of_string s) in
if String.length s = 0
then
let null = pack (Tv_App (`LowStar.Buffer.null) ((`UInt8.t), Q_Implicit)) in
uniq, None, mk_e_app (`LB) [mk_uint32 0; null]
else
let l = normalize_term (String.length s / 2) in
let uniq, se, e = mk_gcmalloc_of_list uniq constants l None in
uniq, Some se, e | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"Test.Lowstarize.gensym",
"Prims.string",
"Prims.op_BarBar",
"Prims.op_disEquality",
"Prims.int",
"Prims.op_Modulus",
"FStar.String.length",
"Prims.op_Negation",
"FStar.List.Tot.Base.for_all",
"FStar.String.char",
"Lib.Meta.is_hex_digit",
"FStar.String.list_of_string",
"FStar.Tactics.V1.Derived.fail",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.sigelt",
"FStar.Reflection.Types.term",
"Prims.op_Hat",
"Prims.bool",
"Prims.op_Equality",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.None",
"FStar.Reflection.V1.Derived.mk_e_app",
"Prims.list",
"Prims.Cons",
"Prims.Nil",
"Test.Lowstarize.mk_uint32",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_App",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.aqualv",
"FStar.Reflection.V1.Data.Q_Implicit",
"FStar.Pervasives.Native.Some",
"Test.Lowstarize.mk_gcmalloc_of_list",
"FStar.Pervasives.normalize_term",
"Prims.op_Division",
"Test.Lowstarize.as_uint8s"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract
let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ]
noextract
let destruct_tuple (e: term): option (list term) =
let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns then
Some (List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> []
) args)
else
None
| _ ->
None
noextract
let is_tuple (e: term) =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
List.Tot.contains (inspect_fv fv) mktuple_qns
| _ ->
false
noextract
let destruct_hex (e: term) =
let hd, tl = collect_app e in
if term_eq (`h) hd && List.Tot.length tl > 0 then begin
destruct_string (fst (List.Tot.hd tl))
end else
None
noextract
let is_hex e =
is_some (destruct_hex e)
// Main Tactic. This tactic fetches a top-level term and defines another,
// Low*-ized top-level term for it, where:
// - hex-encoded strings are lifted as top-level constant uint8 arrays
// - references to hex-encoded strings are replaced by a pair of the length
// of the corresponding array, and a reference to that array
// - lists are lifted as top-level arrays (using gcmalloc_of_list)
// - strings that are not marked as hex-encoded are lifted to C.String.t
// - tuples are traversed transparently
// - everything else is left as-is
//
// TODO: instead of pairs, use a dependent type that ties together an array and
// its length
let gensym = string * nat
noextract
let fresh (uniq: gensym): Tac (gensym * name) =
(fst uniq, snd uniq + 1), cur_module () @ [ fst uniq ^ string_of_int (snd uniq) ]
noeq
type lbuffer (a:Type0) =
| LB: len:UInt32.t -> b:B.buffer a{B.len b == len /\ B.recallable b} -> lbuffer a
noextract
let mk_gcmalloc_of_list (uniq: gensym) (arg: term) (l:int) (t: option term):
Tac (gensym * sigelt * term)
=
let def: term = pack (Tv_App
(pack (Tv_App (`LowStar.Buffer.gcmalloc_of_list) (`HS.root, Q_Explicit)))
(arg, Q_Explicit)
) in
let uniq, name = fresh uniq in
let fv: fv = pack_fv name in
let t: term = match t with None -> pack Tv_Unknown | Some t -> t in
let lb = pack_lb ({lb_fv = fv;
lb_us = [];
lb_typ = t;
lb_def = def}) in
let se: sigelt = pack_sigelt (Sg_Let false [lb]) in
uniq, se, mk_e_app (`LB) [mk_uint32 l; pack (Tv_FVar fv)]
noextract | false | false | Test.Lowstarize.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 lowstarize_hex (uniq: gensym) (s: string) : Tac (gensym * option sigelt * term) | [] | Test.Lowstarize.lowstarize_hex | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | uniq: Test.Lowstarize.gensym -> s: Prims.string
-> FStar.Tactics.Effect.Tac
((Test.Lowstarize.gensym * FStar.Pervasives.Native.option FStar.Reflection.Types.sigelt) *
FStar.Reflection.Types.term) | {
"end_col": 22,
"end_line": 187,
"start_col": 2,
"start_line": 176
} |
FStar.Tactics.Effect.Tac | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false | let is_list e = | true | null | false | match inspect (fst (collect_app e)) with
| Tv_UInst fv _ | Tv_FVar fv -> inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ -> false | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"FStar.Reflection.Types.term",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V1.Data.universes",
"Prims.op_BarBar",
"Prims.op_Equality",
"Prims.list",
"Prims.string",
"FStar.Reflection.V1.Builtins.inspect_fv",
"FStar.Reflection.Const.nil_qn",
"FStar.Reflection.Const.cons_qn",
"FStar.Reflection.V1.Data.term_view",
"Prims.bool",
"FStar.Tactics.V1.Builtins.inspect",
"FStar.Pervasives.Native.fst",
"FStar.Reflection.V1.Data.argv",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.V1.SyntaxHelpers.collect_app"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract | false | false | Test.Lowstarize.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 is_list : e: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool | [] | Test.Lowstarize.is_list | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | e: FStar.Reflection.Types.term -> FStar.Tactics.Effect.Tac Prims.bool | {
"end_col": 11,
"end_line": 88,
"start_col": 2,
"start_line": 83
} |
|
FStar.Tactics.Effect.Tac | val mk_gcmalloc_of_list (uniq: gensym) (arg: term) (l: int) (t: option term)
: Tac (gensym * sigelt * term) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mk_gcmalloc_of_list (uniq: gensym) (arg: term) (l:int) (t: option term):
Tac (gensym * sigelt * term)
=
let def: term = pack (Tv_App
(pack (Tv_App (`LowStar.Buffer.gcmalloc_of_list) (`HS.root, Q_Explicit)))
(arg, Q_Explicit)
) in
let uniq, name = fresh uniq in
let fv: fv = pack_fv name in
let t: term = match t with None -> pack Tv_Unknown | Some t -> t in
let lb = pack_lb ({lb_fv = fv;
lb_us = [];
lb_typ = t;
lb_def = def}) in
let se: sigelt = pack_sigelt (Sg_Let false [lb]) in
uniq, se, mk_e_app (`LB) [mk_uint32 l; pack (Tv_FVar fv)] | val mk_gcmalloc_of_list (uniq: gensym) (arg: term) (l: int) (t: option term)
: Tac (gensym * sigelt * term)
let mk_gcmalloc_of_list (uniq: gensym) (arg: term) (l: int) (t: option term)
: Tac (gensym * sigelt * term) = | true | null | false | let def:term =
pack (Tv_App (pack (Tv_App (`LowStar.Buffer.gcmalloc_of_list) ((`HS.root), Q_Explicit)))
(arg, Q_Explicit))
in
let uniq, name = fresh uniq in
let fv:fv = pack_fv name in
let t:term =
match t with
| None -> pack Tv_Unknown
| Some t -> t
in
let lb = pack_lb ({ lb_fv = fv; lb_us = []; lb_typ = t; lb_def = def }) in
let se:sigelt = pack_sigelt (Sg_Let false [lb]) in
uniq, se, mk_e_app (`LB) [mk_uint32 l; pack (Tv_FVar fv)] | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"Test.Lowstarize.gensym",
"FStar.Reflection.Types.term",
"Prims.int",
"FStar.Pervasives.Native.option",
"FStar.Reflection.Types.name",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Reflection.Types.sigelt",
"FStar.Pervasives.Native.tuple3",
"FStar.Reflection.V1.Derived.mk_e_app",
"Prims.list",
"Prims.Cons",
"Prims.Nil",
"FStar.Tactics.V1.Builtins.pack",
"FStar.Reflection.V1.Data.Tv_FVar",
"Test.Lowstarize.mk_uint32",
"FStar.Reflection.V1.Builtins.pack_sigelt",
"FStar.Reflection.V1.Data.Sg_Let",
"FStar.Reflection.Types.letbinding",
"FStar.Reflection.V1.Builtins.pack_lb",
"FStar.Reflection.V1.Data.Mklb_view",
"FStar.Reflection.V1.Data.univ_name",
"FStar.Reflection.V1.Data.Tv_Unknown",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V1.Builtins.pack_fv",
"FStar.Pervasives.Native.tuple2",
"Test.Lowstarize.fresh",
"FStar.Reflection.V1.Data.term_view",
"FStar.Reflection.V1.Data.Tv_App",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.aqualv",
"FStar.Reflection.V1.Data.Q_Explicit"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract
let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ]
noextract
let destruct_tuple (e: term): option (list term) =
let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns then
Some (List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> []
) args)
else
None
| _ ->
None
noextract
let is_tuple (e: term) =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
List.Tot.contains (inspect_fv fv) mktuple_qns
| _ ->
false
noextract
let destruct_hex (e: term) =
let hd, tl = collect_app e in
if term_eq (`h) hd && List.Tot.length tl > 0 then begin
destruct_string (fst (List.Tot.hd tl))
end else
None
noextract
let is_hex e =
is_some (destruct_hex e)
// Main Tactic. This tactic fetches a top-level term and defines another,
// Low*-ized top-level term for it, where:
// - hex-encoded strings are lifted as top-level constant uint8 arrays
// - references to hex-encoded strings are replaced by a pair of the length
// of the corresponding array, and a reference to that array
// - lists are lifted as top-level arrays (using gcmalloc_of_list)
// - strings that are not marked as hex-encoded are lifted to C.String.t
// - tuples are traversed transparently
// - everything else is left as-is
//
// TODO: instead of pairs, use a dependent type that ties together an array and
// its length
let gensym = string * nat
noextract
let fresh (uniq: gensym): Tac (gensym * name) =
(fst uniq, snd uniq + 1), cur_module () @ [ fst uniq ^ string_of_int (snd uniq) ]
noeq
type lbuffer (a:Type0) =
| LB: len:UInt32.t -> b:B.buffer a{B.len b == len /\ B.recallable b} -> lbuffer a
noextract
let mk_gcmalloc_of_list (uniq: gensym) (arg: term) (l:int) (t: option term): | false | false | Test.Lowstarize.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 mk_gcmalloc_of_list (uniq: gensym) (arg: term) (l: int) (t: option term)
: Tac (gensym * sigelt * term) | [] | Test.Lowstarize.mk_gcmalloc_of_list | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
uniq: Test.Lowstarize.gensym ->
arg: FStar.Reflection.Types.term ->
l: Prims.int ->
t: FStar.Pervasives.Native.option FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
((Test.Lowstarize.gensym * FStar.Reflection.Types.sigelt) * FStar.Reflection.Types.term) | {
"end_col": 59,
"end_line": 172,
"start_col": 1,
"start_line": 159
} |
FStar.Tactics.Effect.Tac | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let destruct_hex (e: term) =
let hd, tl = collect_app e in
if term_eq (`h) hd && List.Tot.length tl > 0 then begin
destruct_string (fst (List.Tot.hd tl))
end else
None | let destruct_hex (e: term) = | true | null | false | let hd, tl = collect_app e in
if term_eq (`h) hd && List.Tot.length tl > 0 then destruct_string (fst (List.Tot.hd tl)) else None | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Reflection.V1.Data.argv",
"Prims.op_AmpAmp",
"FStar.Reflection.V1.Builtins.term_eq",
"Prims.op_GreaterThan",
"FStar.List.Tot.Base.length",
"Test.Lowstarize.destruct_string",
"FStar.Pervasives.Native.fst",
"FStar.Reflection.V1.Data.aqualv",
"FStar.List.Tot.Base.hd",
"Prims.bool",
"FStar.Pervasives.Native.None",
"Prims.string",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"FStar.Tactics.V1.SyntaxHelpers.collect_app"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must"
noextract
let rec destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None
noextract
let is_list e =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
inspect_fv fv = nil_qn || inspect_fv fv = cons_qn
| _ ->
false
noextract
let mktuple_qns =
[ mktuple2_qn; mktuple3_qn; mktuple4_qn; mktuple5_qn; mktuple6_qn;
mktuple7_qn; mktuple8_qn ]
noextract
let destruct_tuple (e: term): option (list term) =
let hd, args = collect_app_ln e in
match inspect_ln hd with
| Tv_UInst fv _
| Tv_FVar fv ->
if List.Tot.contains (inspect_fv fv) mktuple_qns then
Some (List.Tot.concatMap (fun (t, q) ->
match q with
| Q_Explicit -> [t]
| _ -> []
) args)
else
None
| _ ->
None
noextract
let is_tuple (e: term) =
match inspect (fst (collect_app e)) with
| Tv_UInst fv _
| Tv_FVar fv ->
List.Tot.contains (inspect_fv fv) mktuple_qns
| _ ->
false | false | false | Test.Lowstarize.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 destruct_hex : e: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option Prims.string) | [] | Test.Lowstarize.destruct_hex | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | e: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option Prims.string) | {
"end_col": 8,
"end_line": 127,
"start_col": 28,
"start_line": 122
} |
|
FStar.Tactics.Effect.Tac | val destruct_list (e: term) : Tac (option (list term)) | [
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_module": "Test",
"short_module": null
},
{
"abbrev": false,
"full_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 destruct_list (e: term): Tac (option (list term)) =
let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [ _; hd, _; tl, _ ]
| Tv_FVar fv, [ _; hd, _; tl, _ ] ->
if inspect_fv fv = cons_qn then
Some (hd :: must (destruct_list tl))
else
None
| Tv_UInst fv _, _
| Tv_FVar fv, _ ->
if inspect_fv fv = nil_qn then
Some []
else
None
| _ ->
None | val destruct_list (e: term) : Tac (option (list term))
let rec destruct_list (e: term) : Tac (option (list term)) = | true | null | false | let hd, args = collect_app e in
match inspect_ln hd, args with
| Tv_UInst fv _, [_ ; hd, _ ; tl, _]
| Tv_FVar fv, [_ ; hd, _ ; tl, _] ->
if inspect_fv fv = cons_qn then Some (hd :: must (destruct_list tl)) else None
| Tv_UInst fv _, _ | Tv_FVar fv, _ -> if inspect_fv fv = nil_qn then Some [] else None
| _ -> None | {
"checked_file": "Test.Lowstarize.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Meta.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Tactics.fst.checked",
"FStar.String.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Char.fsti.checked",
"C.String.fsti.checked"
],
"interface_file": false,
"source_file": "Test.Lowstarize.fst"
} | [] | [
"FStar.Reflection.Types.term",
"Prims.list",
"FStar.Reflection.V1.Data.argv",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Reflection.V1.Data.term_view",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V1.Data.aqualv",
"FStar.Reflection.V1.Builtins.inspect_ln",
"FStar.Reflection.Types.fv",
"FStar.Reflection.V1.Data.universes",
"Prims.op_Equality",
"Prims.string",
"FStar.Reflection.V1.Builtins.inspect_fv",
"FStar.Reflection.Const.cons_qn",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.option",
"Prims.Cons",
"Test.Lowstarize.must",
"Test.Lowstarize.destruct_list",
"Prims.bool",
"FStar.Pervasives.Native.None",
"FStar.Reflection.Const.nil_qn",
"Prims.Nil",
"FStar.Tactics.V1.SyntaxHelpers.collect_app"
] | [] | module Test.Lowstarize
open FStar.List.Tot
open FStar.Tactics
open LowStar.BufferOps
open Lib.Meta
module B = LowStar.Buffer
module HS = FStar.HyperStack
// We rely on a single user-level function: h, which indicates that the string
// is hex-encoded. Otherwise, the string becomes a call to C.String.of_literal.
assume new type hex_encoded
assume val h: string -> hex_encoded
noextract
let mk_int (i: int): term =
pack_ln (Tv_Const (C_Int i))
noextract
let mk_uint8 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt8";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let mk_uint32 (x: int): Tac term =
pack (Tv_App (pack (Tv_FVar (pack_fv ["FStar";"UInt32";"__uint_to_t"])))
(mk_int x, Q_Explicit))
noextract
let rec as_uint8s acc
(cs:list Char.char{normalize (List.Tot.length cs % 2 = 0) /\
normalize (List.Tot.for_all is_hex_digit cs)}):
Tac term (decreases cs)
=
match cs with
| c1 :: c2 :: cs ->
as_uint8s (mk_uint8 (byte_of_hex c1 c2) :: acc) cs
| [] ->
mk_list (List.rev acc)
noextract
let destruct_string e =
match inspect_ln e with
| Tv_Const (C_String s) -> Some s
| _ -> None
noextract
let is_some = function Some _ -> true | None -> false
noextract
let is_string e =
is_some (destruct_string e)
noextract
let must (x: option 'a): Tac 'a =
match x with
| Some x -> x
| None -> fail "must" | false | false | Test.Lowstarize.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 destruct_list (e: term) : Tac (option (list term)) | [
"recursion"
] | Test.Lowstarize.destruct_list | {
"file_name": "providers/test/Test.Lowstarize.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | e: FStar.Reflection.Types.term
-> FStar.Tactics.Effect.Tac
(FStar.Pervasives.Native.option (Prims.list FStar.Reflection.Types.term)) | {
"end_col": 10,
"end_line": 79,
"start_col": 59,
"start_line": 63
} |
FStar.Pervasives.Lemma | val add_mod_small: a:nat -> b:nat -> n:pos -> Lemma
(requires a % n + b % n < n)
(ensures a % n + b % n == (a + b) % n) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_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_small a b n =
FStar.Math.Lemmas.modulo_lemma (a % n + b % n) n;
assert (a % n + b % n == (a % n + b % n) % n);
FStar.Math.Lemmas.lemma_mod_plus_distr_l a (b % n) n;
FStar.Math.Lemmas.lemma_mod_plus_distr_r a b n | val add_mod_small: a:nat -> b:nat -> n:pos -> Lemma
(requires a % n + b % n < n)
(ensures a % n + b % n == (a + b) % n)
let add_mod_small a b n = | false | null | true | FStar.Math.Lemmas.modulo_lemma (a % n + b % n) n;
assert (a % n + b % n == (a % n + b % n) % n);
FStar.Math.Lemmas.lemma_mod_plus_distr_l a (b % n) n;
FStar.Math.Lemmas.lemma_mod_plus_distr_r a b n | {
"checked_file": "Hacl.Impl.Poly1305.Bignum128.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.Bignum128.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Prims.pos",
"FStar.Math.Lemmas.lemma_mod_plus_distr_r",
"Prims.unit",
"FStar.Math.Lemmas.lemma_mod_plus_distr_l",
"Prims.op_Modulus",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Addition",
"FStar.Math.Lemmas.modulo_lemma"
] | [] | module Hacl.Impl.Poly1305.Bignum128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Lemmas
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
friend FStar.UInt128
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let uints64_from_bytes_le b =
let h0 = ST.get () in
let lo = uint_from_bytes_le #U64 (sub b 0ul 8ul) in
let hi = uint_from_bytes_le #U64 (sub b 8ul 8ul) in
uint_from_bytes_le_lemma (as_seq h0 b);
lo, hi
let uints64_to_bytes_le b r0 r1 =
let h0 = ST.get () in
update_sub_f h0 b 0ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r0)
(fun _ -> uint_to_bytes_le (sub b 0ul 8ul) r0);
let h1 = ST.get () in
update_sub_f h1 b 8ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r1)
(fun _ -> uint_to_bytes_le (sub b 8ul 8ul) r1);
//uint_to_bytes_le (sub b 0ul 8ul) r0;
//uint_to_bytes_le (sub b 8ul 8ul) r1;
let h2 = ST.get () in
uints64_to_bytes_le_lemma r0 r1;
LSeq.eq_intro (LSeq.sub (as_seq h2 b) 0 8) (BSeq.uint_to_bytes_le #U64 r0);
LSeq.lemma_concat2
8 (BSeq.uint_to_bytes_le #U64 r0)
8 (BSeq.uint_to_bytes_le #U64 r1) (as_seq h2 b)
val constant_time_carry_ok: r0:uint64 -> b0:uint64 ->
Lemma (let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
v c == (if v r0 < v b0 then 1 else 0))
let constant_time_carry_ok r0 b0 =
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r0' = Lib.RawIntTypes.u64_to_UInt64 r0 in
let b0' = Lib.RawIntTypes.u64_to_UInt64 b0 in
let c' = FStar.UInt128.constant_time_carry r0' b0' in
logxor_spec r0 b0;
logxor_spec (r0 -. b0) b0;
logor_spec (r0 ^. b0) ((r0 -. b0) ^. b0);
logxor_spec r0 ((r0 ^. b0) |. ((r0 -. b0) ^. b0));
assert (v c' == v c);
FStar.UInt128.constant_time_carry_ok r0' b0'
val add_mod_small: a:nat -> b:nat -> n:pos -> Lemma
(requires a % n + b % n < n)
(ensures a % n + b % n == (a + b) % n) | false | false | Hacl.Impl.Poly1305.Bignum128.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 add_mod_small: a:nat -> b:nat -> n:pos -> Lemma
(requires a % n + b % n < n)
(ensures a % n + b % n == (a + b) % n) | [] | Hacl.Impl.Poly1305.Bignum128.add_mod_small | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.Bignum128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.nat -> b: Prims.nat -> n: Prims.pos
-> FStar.Pervasives.Lemma (requires a % n + b % n < n) (ensures a % n + b % n == (a + b) % n) | {
"end_col": 48,
"end_line": 73,
"start_col": 2,
"start_line": 70
} |
FStar.HyperStack.ST.Stack | val uints64_from_bytes_le: b:lbuffer uint8 16ul ->
Stack (uint64 & uint64)
(requires fun h -> live h b)
(ensures fun h0 (lo, hi) h1 -> h0 == h1 /\
v hi * pow2 64 + v lo == BSeq.nat_from_bytes_le (as_seq h0 b)) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uints64_from_bytes_le b =
let h0 = ST.get () in
let lo = uint_from_bytes_le #U64 (sub b 0ul 8ul) in
let hi = uint_from_bytes_le #U64 (sub b 8ul 8ul) in
uint_from_bytes_le_lemma (as_seq h0 b);
lo, hi | val uints64_from_bytes_le: b:lbuffer uint8 16ul ->
Stack (uint64 & uint64)
(requires fun h -> live h b)
(ensures fun h0 (lo, hi) h1 -> h0 == h1 /\
v hi * pow2 64 + v lo == BSeq.nat_from_bytes_le (as_seq h0 b))
let uints64_from_bytes_le b = | true | null | false | let h0 = ST.get () in
let lo = uint_from_bytes_le #U64 (sub b 0ul 8ul) in
let hi = uint_from_bytes_le #U64 (sub b 8ul 8ul) in
uint_from_bytes_le_lemma (as_seq h0 b);
lo, hi | {
"checked_file": "Hacl.Impl.Poly1305.Bignum128.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.Bignum128.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.uint64",
"Prims.unit",
"Hacl.Impl.Poly1305.Lemmas.uint_from_bytes_le_lemma",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.ByteBuffer.uint_from_bytes_le",
"Lib.IntTypes.uint_t",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.mk_int",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.sub",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Impl.Poly1305.Bignum128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Lemmas
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
friend FStar.UInt128
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | false | Hacl.Impl.Poly1305.Bignum128.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 uints64_from_bytes_le: b:lbuffer uint8 16ul ->
Stack (uint64 & uint64)
(requires fun h -> live h b)
(ensures fun h0 (lo, hi) h1 -> h0 == h1 /\
v hi * pow2 64 + v lo == BSeq.nat_from_bytes_le (as_seq h0 b)) | [] | Hacl.Impl.Poly1305.Bignum128.uints64_from_bytes_le | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.Bignum128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul
-> FStar.HyperStack.ST.Stack (Lib.IntTypes.uint64 * Lib.IntTypes.uint64) | {
"end_col": 8,
"end_line": 26,
"start_col": 29,
"start_line": 21
} |
Prims.Pure | val mod_add128:
a:(uint64 & uint64)
-> b:(uint64 & uint64) ->
Pure (uint64 & uint64)
(requires True)
(ensures (fun (r0, r1) ->
let (a0, a1) = a in let (b0, b1) = b in
v r1 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128)) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_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_add128 (a0, a1) (b0, b1) =
mod_add128_lemma (a0, a1) (b0, b1);
let r0 = a0 +. b0 in
let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r1 = r1 +. c in
(r0, r1) | val mod_add128:
a:(uint64 & uint64)
-> b:(uint64 & uint64) ->
Pure (uint64 & uint64)
(requires True)
(ensures (fun (r0, r1) ->
let (a0, a1) = a in let (b0, b1) = b in
v r1 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128))
let mod_add128 (a0, a1) (b0, b1) = | false | null | false | mod_add128_lemma (a0, a1) (b0, b1);
let r0 = a0 +. b0 in
let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r1 = r1 +. c in
(r0, r1) | {
"checked_file": "Hacl.Impl.Poly1305.Bignum128.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.Bignum128.fst"
} | [] | [
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.uint64",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Plus_Dot",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Lib.IntTypes.op_Hat_Dot",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.op_Subtraction_Dot",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Hacl.Impl.Poly1305.Bignum128.mod_add128_lemma"
] | [] | module Hacl.Impl.Poly1305.Bignum128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Lemmas
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
friend FStar.UInt128
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let uints64_from_bytes_le b =
let h0 = ST.get () in
let lo = uint_from_bytes_le #U64 (sub b 0ul 8ul) in
let hi = uint_from_bytes_le #U64 (sub b 8ul 8ul) in
uint_from_bytes_le_lemma (as_seq h0 b);
lo, hi
let uints64_to_bytes_le b r0 r1 =
let h0 = ST.get () in
update_sub_f h0 b 0ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r0)
(fun _ -> uint_to_bytes_le (sub b 0ul 8ul) r0);
let h1 = ST.get () in
update_sub_f h1 b 8ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r1)
(fun _ -> uint_to_bytes_le (sub b 8ul 8ul) r1);
//uint_to_bytes_le (sub b 0ul 8ul) r0;
//uint_to_bytes_le (sub b 8ul 8ul) r1;
let h2 = ST.get () in
uints64_to_bytes_le_lemma r0 r1;
LSeq.eq_intro (LSeq.sub (as_seq h2 b) 0 8) (BSeq.uint_to_bytes_le #U64 r0);
LSeq.lemma_concat2
8 (BSeq.uint_to_bytes_le #U64 r0)
8 (BSeq.uint_to_bytes_le #U64 r1) (as_seq h2 b)
val constant_time_carry_ok: r0:uint64 -> b0:uint64 ->
Lemma (let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
v c == (if v r0 < v b0 then 1 else 0))
let constant_time_carry_ok r0 b0 =
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r0' = Lib.RawIntTypes.u64_to_UInt64 r0 in
let b0' = Lib.RawIntTypes.u64_to_UInt64 b0 in
let c' = FStar.UInt128.constant_time_carry r0' b0' in
logxor_spec r0 b0;
logxor_spec (r0 -. b0) b0;
logor_spec (r0 ^. b0) ((r0 -. b0) ^. b0);
logxor_spec r0 ((r0 ^. b0) |. ((r0 -. b0) ^. b0));
assert (v c' == v c);
FStar.UInt128.constant_time_carry_ok r0' b0'
val add_mod_small: a:nat -> b:nat -> n:pos -> Lemma
(requires a % n + b % n < n)
(ensures a % n + b % n == (a + b) % n)
let add_mod_small a b n =
FStar.Math.Lemmas.modulo_lemma (a % n + b % n) n;
assert (a % n + b % n == (a % n + b % n) % n);
FStar.Math.Lemmas.lemma_mod_plus_distr_l a (b % n) n;
FStar.Math.Lemmas.lemma_mod_plus_distr_r a b n
val mod_add128_lemma: a:(uint64 & uint64) -> b:(uint64 & uint64) ->
Lemma (let (a0, a1) = a in let (b0, b1) = b in
let r0 = a0 +. b0 in let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r1 = r1 +. c in
v r1 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128)
let mod_add128_lemma a b =
let (a0, a1) = a in
let (b0, b1) = b in
let r0 = a0 +. b0 in
let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
constant_time_carry_ok r0 b0;
assert (v c == (if v r0 < v b0 then 1 else 0));
assert (v c == (v a0 + v b0) / pow2 64);
let r2 = r1 +. c in
calc (==) {
v r2 * pow2 64 + v r0;
(==) { }
((v a1 + v b1) % pow2 64 + (v a0 + v b0) / pow2 64) % pow2 64 * pow2 64 + (v a0 + v b0) % pow2 64;
(==) { Math.Lemmas.pow2_multiplication_modulo_lemma_2 ((v a1 + v b1) % pow2 64 + (v a0 + v b0) / pow2 64) 128 64 }
((v a1 + v b1) % pow2 64 + (v a0 + v b0) / pow2 64) * pow2 64 % pow2 128 + (v a0 + v b0) % pow2 64;
(==) { }
((v a1 + v b1) % pow2 64 * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + (v a0 + v b0) % pow2 64;
(==) { Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v a1 + v b1) 128 64 }
((v a1 + v b1) * pow2 64 % pow2 128 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + (v a0 + v b0) % pow2 64;
(==) { Math.Lemmas.lemma_mod_plus_distr_l ((v a1 + v b1) * pow2 64) ((v a0 + v b0) / pow2 64 * pow2 64) (pow2 128) }
((v a1 + v b1) * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + (v a0 + v b0) % pow2 64;
(==) { Math.Lemmas.modulo_lemma ((v a0 + v b0) % pow2 64) (pow2 128) }
((v a1 + v b1) * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + ((v a0 + v b0) % pow2 64) % pow2 128;
};
assert (v r2 * pow2 64 + v r0 ==
((v a1 + v b1) * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + ((v a0 + v b0) % pow2 64) % pow2 128);
assert (v r2 * pow2 64 + v r0 < pow2 128);
add_mod_small ((v a1 + v b1) * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) ((v a0 + v b0) % pow2 64) (pow2 128);
Math.Lemmas.euclidean_division_definition (v a0 + v b0) (pow2 64);
assert (v r2 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128) | false | false | Hacl.Impl.Poly1305.Bignum128.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 mod_add128:
a:(uint64 & uint64)
-> b:(uint64 & uint64) ->
Pure (uint64 & uint64)
(requires True)
(ensures (fun (r0, r1) ->
let (a0, a1) = a in let (b0, b1) = b in
v r1 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128)) | [] | Hacl.Impl.Poly1305.Bignum128.mod_add128 | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.Bignum128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: (Lib.IntTypes.uint64 * Lib.IntTypes.uint64) -> b: (Lib.IntTypes.uint64 * Lib.IntTypes.uint64)
-> Prims.Pure (Lib.IntTypes.uint64 * Lib.IntTypes.uint64) | {
"end_col": 10,
"end_line": 123,
"start_col": 2,
"start_line": 118
} |
FStar.Pervasives.Lemma | val constant_time_carry_ok: r0:uint64 -> b0:uint64 ->
Lemma (let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
v c == (if v r0 < v b0 then 1 else 0)) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let constant_time_carry_ok r0 b0 =
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r0' = Lib.RawIntTypes.u64_to_UInt64 r0 in
let b0' = Lib.RawIntTypes.u64_to_UInt64 b0 in
let c' = FStar.UInt128.constant_time_carry r0' b0' in
logxor_spec r0 b0;
logxor_spec (r0 -. b0) b0;
logor_spec (r0 ^. b0) ((r0 -. b0) ^. b0);
logxor_spec r0 ((r0 ^. b0) |. ((r0 -. b0) ^. b0));
assert (v c' == v c);
FStar.UInt128.constant_time_carry_ok r0' b0' | val constant_time_carry_ok: r0:uint64 -> b0:uint64 ->
Lemma (let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
v c == (if v r0 < v b0 then 1 else 0))
let constant_time_carry_ok r0 b0 = | false | null | true | let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r0' = Lib.RawIntTypes.u64_to_UInt64 r0 in
let b0' = Lib.RawIntTypes.u64_to_UInt64 b0 in
let c' = FStar.UInt128.constant_time_carry r0' b0' in
logxor_spec r0 b0;
logxor_spec (r0 -. b0) b0;
logor_spec (r0 ^. b0) ((r0 -. b0) ^. b0);
logxor_spec r0 ((r0 ^. b0) |. ((r0 -. b0) ^. b0));
assert (v c' == v c);
FStar.UInt128.constant_time_carry_ok r0' b0' | {
"checked_file": "Hacl.Impl.Poly1305.Bignum128.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.Bignum128.fst"
} | [
"lemma"
] | [
"Lib.IntTypes.uint64",
"FStar.UInt128.constant_time_carry_ok",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.IntTypes.range_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.v",
"Lib.IntTypes.PUB",
"Lib.IntTypes.SEC",
"Lib.IntTypes.logxor_spec",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.op_Hat_Dot",
"Lib.IntTypes.op_Subtraction_Dot",
"Lib.IntTypes.logor_spec",
"FStar.UInt64.t",
"FStar.UInt128.constant_time_carry",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"FStar.UInt.size",
"FStar.UInt64.v",
"Lib.RawIntTypes.u64_to_UInt64",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Poly1305.Bignum128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Lemmas
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
friend FStar.UInt128
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let uints64_from_bytes_le b =
let h0 = ST.get () in
let lo = uint_from_bytes_le #U64 (sub b 0ul 8ul) in
let hi = uint_from_bytes_le #U64 (sub b 8ul 8ul) in
uint_from_bytes_le_lemma (as_seq h0 b);
lo, hi
let uints64_to_bytes_le b r0 r1 =
let h0 = ST.get () in
update_sub_f h0 b 0ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r0)
(fun _ -> uint_to_bytes_le (sub b 0ul 8ul) r0);
let h1 = ST.get () in
update_sub_f h1 b 8ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r1)
(fun _ -> uint_to_bytes_le (sub b 8ul 8ul) r1);
//uint_to_bytes_le (sub b 0ul 8ul) r0;
//uint_to_bytes_le (sub b 8ul 8ul) r1;
let h2 = ST.get () in
uints64_to_bytes_le_lemma r0 r1;
LSeq.eq_intro (LSeq.sub (as_seq h2 b) 0 8) (BSeq.uint_to_bytes_le #U64 r0);
LSeq.lemma_concat2
8 (BSeq.uint_to_bytes_le #U64 r0)
8 (BSeq.uint_to_bytes_le #U64 r1) (as_seq h2 b)
val constant_time_carry_ok: r0:uint64 -> b0:uint64 ->
Lemma (let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
v c == (if v r0 < v b0 then 1 else 0)) | false | false | Hacl.Impl.Poly1305.Bignum128.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 constant_time_carry_ok: r0:uint64 -> b0:uint64 ->
Lemma (let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
v c == (if v r0 < v b0 then 1 else 0)) | [] | Hacl.Impl.Poly1305.Bignum128.constant_time_carry_ok | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.Bignum128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | r0: Lib.IntTypes.uint64 -> b0: Lib.IntTypes.uint64
-> FStar.Pervasives.Lemma
(ensures
(let c = r0 ^. (r0 ^. b0 |. r0 -. b0 ^. b0) >>. 63ul in
Lib.IntTypes.v c ==
(match Lib.IntTypes.v r0 < Lib.IntTypes.v b0 with
| true -> 1
| _ -> 0))) | {
"end_col": 46,
"end_line": 62,
"start_col": 34,
"start_line": 52
} |
FStar.HyperStack.ST.Stack | val uints64_to_bytes_le:
b:lbuffer uint8 16ul
-> lo:uint64
-> hi:uint64 ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 ->
modifies (loc b) h0 h1 /\
as_seq h1 b == BSeq.nat_to_bytes_le 16 (v hi * pow2 64 + v lo)) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uints64_to_bytes_le b r0 r1 =
let h0 = ST.get () in
update_sub_f h0 b 0ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r0)
(fun _ -> uint_to_bytes_le (sub b 0ul 8ul) r0);
let h1 = ST.get () in
update_sub_f h1 b 8ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r1)
(fun _ -> uint_to_bytes_le (sub b 8ul 8ul) r1);
//uint_to_bytes_le (sub b 0ul 8ul) r0;
//uint_to_bytes_le (sub b 8ul 8ul) r1;
let h2 = ST.get () in
uints64_to_bytes_le_lemma r0 r1;
LSeq.eq_intro (LSeq.sub (as_seq h2 b) 0 8) (BSeq.uint_to_bytes_le #U64 r0);
LSeq.lemma_concat2
8 (BSeq.uint_to_bytes_le #U64 r0)
8 (BSeq.uint_to_bytes_le #U64 r1) (as_seq h2 b) | val uints64_to_bytes_le:
b:lbuffer uint8 16ul
-> lo:uint64
-> hi:uint64 ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 ->
modifies (loc b) h0 h1 /\
as_seq h1 b == BSeq.nat_to_bytes_le 16 (v hi * pow2 64 + v lo))
let uints64_to_bytes_le b r0 r1 = | true | null | false | let h0 = ST.get () in
update_sub_f h0
b
0ul
8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r0)
(fun _ -> uint_to_bytes_le (sub b 0ul 8ul) r0);
let h1 = ST.get () in
update_sub_f h1
b
8ul
8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r1)
(fun _ -> uint_to_bytes_le (sub b 8ul 8ul) r1);
let h2 = ST.get () in
uints64_to_bytes_le_lemma r0 r1;
LSeq.eq_intro (LSeq.sub (as_seq h2 b) 0 8) (BSeq.uint_to_bytes_le #U64 r0);
LSeq.lemma_concat2 8 (BSeq.uint_to_bytes_le #U64 r0) 8 (BSeq.uint_to_bytes_le #U64 r1) (as_seq h2 b) | {
"checked_file": "Hacl.Impl.Poly1305.Bignum128.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.Bignum128.fst"
} | [] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.uint64",
"Lib.Sequence.lemma_concat2",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.ByteSequence.uint_to_bytes_le",
"Lib.IntTypes.U64",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.Sequence.eq_intro",
"Lib.Sequence.sub",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Impl.Poly1305.Lemmas.uints64_to_bytes_le_lemma",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.update_sub_f",
"Lib.Sequence.lseq",
"Lib.ByteBuffer.uint_to_bytes_le",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub"
] | [] | module Hacl.Impl.Poly1305.Bignum128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Lemmas
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
friend FStar.UInt128
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let uints64_from_bytes_le b =
let h0 = ST.get () in
let lo = uint_from_bytes_le #U64 (sub b 0ul 8ul) in
let hi = uint_from_bytes_le #U64 (sub b 8ul 8ul) in
uint_from_bytes_le_lemma (as_seq h0 b);
lo, hi | false | false | Hacl.Impl.Poly1305.Bignum128.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 uints64_to_bytes_le:
b:lbuffer uint8 16ul
-> lo:uint64
-> hi:uint64 ->
Stack unit
(requires fun h -> live h b)
(ensures fun h0 _ h1 ->
modifies (loc b) h0 h1 /\
as_seq h1 b == BSeq.nat_to_bytes_le 16 (v hi * pow2 64 + v lo)) | [] | Hacl.Impl.Poly1305.Bignum128.uints64_to_bytes_le | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.Bignum128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Lib.Buffer.lbuffer Lib.IntTypes.uint8 16ul -> lo: Lib.IntTypes.uint64 -> hi: Lib.IntTypes.uint64
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 51,
"end_line": 45,
"start_col": 33,
"start_line": 29
} |
FStar.Pervasives.Lemma | val mod_add128_lemma: a:(uint64 & uint64) -> b:(uint64 & uint64) ->
Lemma (let (a0, a1) = a in let (b0, b1) = b in
let r0 = a0 +. b0 in let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r1 = r1 +. c in
v r1 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128) | [
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Poly1305",
"short_module": null
},
{
"abbrev": false,
"full_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_add128_lemma a b =
let (a0, a1) = a in
let (b0, b1) = b in
let r0 = a0 +. b0 in
let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
constant_time_carry_ok r0 b0;
assert (v c == (if v r0 < v b0 then 1 else 0));
assert (v c == (v a0 + v b0) / pow2 64);
let r2 = r1 +. c in
calc (==) {
v r2 * pow2 64 + v r0;
(==) { }
((v a1 + v b1) % pow2 64 + (v a0 + v b0) / pow2 64) % pow2 64 * pow2 64 + (v a0 + v b0) % pow2 64;
(==) { Math.Lemmas.pow2_multiplication_modulo_lemma_2 ((v a1 + v b1) % pow2 64 + (v a0 + v b0) / pow2 64) 128 64 }
((v a1 + v b1) % pow2 64 + (v a0 + v b0) / pow2 64) * pow2 64 % pow2 128 + (v a0 + v b0) % pow2 64;
(==) { }
((v a1 + v b1) % pow2 64 * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + (v a0 + v b0) % pow2 64;
(==) { Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v a1 + v b1) 128 64 }
((v a1 + v b1) * pow2 64 % pow2 128 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + (v a0 + v b0) % pow2 64;
(==) { Math.Lemmas.lemma_mod_plus_distr_l ((v a1 + v b1) * pow2 64) ((v a0 + v b0) / pow2 64 * pow2 64) (pow2 128) }
((v a1 + v b1) * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + (v a0 + v b0) % pow2 64;
(==) { Math.Lemmas.modulo_lemma ((v a0 + v b0) % pow2 64) (pow2 128) }
((v a1 + v b1) * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + ((v a0 + v b0) % pow2 64) % pow2 128;
};
assert (v r2 * pow2 64 + v r0 ==
((v a1 + v b1) * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) % pow2 128 + ((v a0 + v b0) % pow2 64) % pow2 128);
assert (v r2 * pow2 64 + v r0 < pow2 128);
add_mod_small ((v a1 + v b1) * pow2 64 + (v a0 + v b0) / pow2 64 * pow2 64) ((v a0 + v b0) % pow2 64) (pow2 128);
Math.Lemmas.euclidean_division_definition (v a0 + v b0) (pow2 64);
assert (v r2 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128) | val mod_add128_lemma: a:(uint64 & uint64) -> b:(uint64 & uint64) ->
Lemma (let (a0, a1) = a in let (b0, b1) = b in
let r0 = a0 +. b0 in let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r1 = r1 +. c in
v r1 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128)
let mod_add128_lemma a b = | false | null | true | let a0, a1 = a in
let b0, b1 = b in
let r0 = a0 +. b0 in
let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
constant_time_carry_ok r0 b0;
assert (v c == (if v r0 < v b0 then 1 else 0));
assert (v c == (v a0 + v b0) / pow2 64);
let r2 = r1 +. c in
calc ( == ) {
v r2 * pow2 64 + v r0;
( == ) { () }
(((v a1 + v b1) % pow2 64 + (v a0 + v b0) / pow2 64) % pow2 64) * pow2 64 +
(v a0 + v b0) % pow2 64;
( == ) { Math.Lemmas.pow2_multiplication_modulo_lemma_2 ((v a1 + v b1) % pow2 64 +
(v a0 + v b0) / pow2 64)
128
64 }
((v a1 + v b1) % pow2 64 + (v a0 + v b0) / pow2 64) * pow2 64 % pow2 128 + (v a0 + v b0) % pow2 64;
( == ) { () }
(((v a1 + v b1) % pow2 64) * pow2 64 + ((v a0 + v b0) / pow2 64) * pow2 64) % pow2 128 +
(v a0 + v b0) % pow2 64;
( == ) { Math.Lemmas.pow2_multiplication_modulo_lemma_2 (v a1 + v b1) 128 64 }
((v a1 + v b1) * pow2 64 % pow2 128 + ((v a0 + v b0) / pow2 64) * pow2 64) % pow2 128 +
(v a0 + v b0) % pow2 64;
( == ) { Math.Lemmas.lemma_mod_plus_distr_l ((v a1 + v b1) * pow2 64)
(((v a0 + v b0) / pow2 64) * pow2 64)
(pow2 128) }
((v a1 + v b1) * pow2 64 + ((v a0 + v b0) / pow2 64) * pow2 64) % pow2 128 +
(v a0 + v b0) % pow2 64;
( == ) { Math.Lemmas.modulo_lemma ((v a0 + v b0) % pow2 64) (pow2 128) }
((v a1 + v b1) * pow2 64 + ((v a0 + v b0) / pow2 64) * pow2 64) % pow2 128 +
((v a0 + v b0) % pow2 64) % pow2 128;
};
assert (v r2 * pow2 64 + v r0 ==
((v a1 + v b1) * pow2 64 + ((v a0 + v b0) / pow2 64) * pow2 64) % pow2 128 +
((v a0 + v b0) % pow2 64) % pow2 128);
assert (v r2 * pow2 64 + v r0 < pow2 128);
add_mod_small ((v a1 + v b1) * pow2 64 + ((v a0 + v b0) / pow2 64) * pow2 64)
((v a0 + v b0) % pow2 64)
(pow2 128);
Math.Lemmas.euclidean_division_definition (v a0 + v b0) (pow2 64);
assert (v r2 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128) | {
"checked_file": "Hacl.Impl.Poly1305.Bignum128.fst.checked",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Poly1305.Lemmas.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt128.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.Poly1305.Bignum128.fst"
} | [
"lemma"
] | [
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.uint64",
"Prims._assert",
"Prims.eq2",
"Prims.int",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Prims.pow2",
"Prims.op_Modulus",
"Prims.unit",
"FStar.Math.Lemmas.euclidean_division_definition",
"Hacl.Impl.Poly1305.Bignum128.add_mod_small",
"Prims.op_Division",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Calc.calc_finish",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Prims.squash",
"FStar.Math.Lemmas.pow2_multiplication_modulo_lemma_2",
"FStar.Math.Lemmas.lemma_mod_plus_distr_l",
"FStar.Math.Lemmas.modulo_lemma",
"Lib.IntTypes.int_t",
"Lib.IntTypes.op_Plus_Dot",
"Prims.bool",
"Hacl.Impl.Poly1305.Bignum128.constant_time_carry_ok",
"Lib.IntTypes.op_Greater_Greater_Dot",
"Lib.IntTypes.op_Hat_Dot",
"Lib.IntTypes.op_Bar_Dot",
"Lib.IntTypes.op_Subtraction_Dot",
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.Impl.Poly1305.Bignum128
open FStar.HyperStack
open FStar.HyperStack.All
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Poly1305.Lemmas
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module BSeq = Lib.ByteSequence
friend FStar.UInt128
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let uints64_from_bytes_le b =
let h0 = ST.get () in
let lo = uint_from_bytes_le #U64 (sub b 0ul 8ul) in
let hi = uint_from_bytes_le #U64 (sub b 8ul 8ul) in
uint_from_bytes_le_lemma (as_seq h0 b);
lo, hi
let uints64_to_bytes_le b r0 r1 =
let h0 = ST.get () in
update_sub_f h0 b 0ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r0)
(fun _ -> uint_to_bytes_le (sub b 0ul 8ul) r0);
let h1 = ST.get () in
update_sub_f h1 b 8ul 8ul
(fun h -> BSeq.uint_to_bytes_le #U64 r1)
(fun _ -> uint_to_bytes_le (sub b 8ul 8ul) r1);
//uint_to_bytes_le (sub b 0ul 8ul) r0;
//uint_to_bytes_le (sub b 8ul 8ul) r1;
let h2 = ST.get () in
uints64_to_bytes_le_lemma r0 r1;
LSeq.eq_intro (LSeq.sub (as_seq h2 b) 0 8) (BSeq.uint_to_bytes_le #U64 r0);
LSeq.lemma_concat2
8 (BSeq.uint_to_bytes_le #U64 r0)
8 (BSeq.uint_to_bytes_le #U64 r1) (as_seq h2 b)
val constant_time_carry_ok: r0:uint64 -> b0:uint64 ->
Lemma (let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
v c == (if v r0 < v b0 then 1 else 0))
let constant_time_carry_ok r0 b0 =
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r0' = Lib.RawIntTypes.u64_to_UInt64 r0 in
let b0' = Lib.RawIntTypes.u64_to_UInt64 b0 in
let c' = FStar.UInt128.constant_time_carry r0' b0' in
logxor_spec r0 b0;
logxor_spec (r0 -. b0) b0;
logor_spec (r0 ^. b0) ((r0 -. b0) ^. b0);
logxor_spec r0 ((r0 ^. b0) |. ((r0 -. b0) ^. b0));
assert (v c' == v c);
FStar.UInt128.constant_time_carry_ok r0' b0'
val add_mod_small: a:nat -> b:nat -> n:pos -> Lemma
(requires a % n + b % n < n)
(ensures a % n + b % n == (a + b) % n)
let add_mod_small a b n =
FStar.Math.Lemmas.modulo_lemma (a % n + b % n) n;
assert (a % n + b % n == (a % n + b % n) % n);
FStar.Math.Lemmas.lemma_mod_plus_distr_l a (b % n) n;
FStar.Math.Lemmas.lemma_mod_plus_distr_r a b n
val mod_add128_lemma: a:(uint64 & uint64) -> b:(uint64 & uint64) ->
Lemma (let (a0, a1) = a in let (b0, b1) = b in
let r0 = a0 +. b0 in let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r1 = r1 +. c in
v r1 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128) | false | false | Hacl.Impl.Poly1305.Bignum128.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 mod_add128_lemma: a:(uint64 & uint64) -> b:(uint64 & uint64) ->
Lemma (let (a0, a1) = a in let (b0, b1) = b in
let r0 = a0 +. b0 in let r1 = a1 +. b1 in
let c = r0 ^. ((r0 ^. b0) |. ((r0 -. b0) ^. b0)) >>. 63ul in
let r1 = r1 +. c in
v r1 * pow2 64 + v r0 == ((v a1 + v b1) * pow2 64 + v a0 + v b0) % pow2 128) | [] | Hacl.Impl.Poly1305.Bignum128.mod_add128_lemma | {
"file_name": "code/poly1305/Hacl.Impl.Poly1305.Bignum128.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: (Lib.IntTypes.uint64 * Lib.IntTypes.uint64) -> b: (Lib.IntTypes.uint64 * Lib.IntTypes.uint64)
-> FStar.Pervasives.Lemma
(ensures
(let _ = a in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ a0 a1 = _ in
let _ = b in
(let FStar.Pervasives.Native.Mktuple2 #_ #_ b0 b1 = _ in
let r0 = a0 +. b0 in
let r1 = a1 +. b1 in
let c = r0 ^. (r0 ^. b0 |. r0 -. b0 ^. b0) >>. 63ul in
let r1 = r1 +. c in
Lib.IntTypes.v r1 * Prims.pow2 64 + Lib.IntTypes.v r0 ==
((Lib.IntTypes.v a1 + Lib.IntTypes.v b1) * Prims.pow2 64 + Lib.IntTypes.v a0 +
Lib.IntTypes.v b0) %
Prims.pow2 128)
<:
Type0)
<:
Type0)) | {
"end_col": 86,
"end_line": 114,
"start_col": 26,
"start_line": 83
} |
Prims.Tot | val list_as_vprop' (vp: vprop) (fvps: list vprop) : Tot vprop (decreases fvps) | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_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 list_as_vprop' (vp:vprop) (fvps:list vprop)
: Tot vprop (decreases fvps) =
match fvps with
| [] -> vp
| hd::tl -> list_as_vprop' (tm_star vp hd) tl | val list_as_vprop' (vp: vprop) (fvps: list vprop) : Tot vprop (decreases fvps)
let rec list_as_vprop' (vp: vprop) (fvps: list vprop) : Tot vprop (decreases fvps) = | false | null | false | match fvps with
| [] -> vp
| hd :: tl -> list_as_vprop' (tm_star vp hd) tl | {
"checked_file": "Pulse.Checker.Prover.Base.fst.checked",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.VPropEquiv.fsti.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Base.fst"
} | [
"total",
""
] | [
"Pulse.Syntax.Base.vprop",
"Prims.list",
"Pulse.Checker.Prover.Base.list_as_vprop'",
"Pulse.Syntax.Base.tm_star"
] | [] | module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Base
open Pulse.Typing.Combinators
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs
let rec list_as_vprop' (vp:vprop) (fvps:list vprop) | false | true | Pulse.Checker.Prover.Base.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 list_as_vprop' (vp: vprop) (fvps: list vprop) : Tot vprop (decreases fvps) | [
"recursion"
] | Pulse.Checker.Prover.Base.list_as_vprop' | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | vp: Pulse.Syntax.Base.vprop -> fvps: Prims.list Pulse.Syntax.Base.vprop
-> Prims.Tot Pulse.Syntax.Base.vprop | {
"end_col": 47,
"end_line": 15,
"start_col": 2,
"start_line": 13
} |
FStar.Tactics.Effect.Tac | val add_elims_aux
(#g: env)
(#ctxt #frame: term)
(f: (vprop -> T.Tac bool))
(mk: mk_t)
(ctxt_frame_typing: tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs: env{disjoint uvs g})
: T.Tac
(bool &
(g': env{env_extends g' g /\ disjoint uvs g'} &
ctxt': term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))) | [
{
"abbrev": true,
"full_module": "Pulse.Checker.VPropEquiv",
"short_module": "VP"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_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_elims_aux (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_frame_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (bool &
(g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame)))
= let (| ctxt', ctxt'_typing, k |) = canon_right ctxt_frame_typing f in
let progress, (| g', ctxt'', ctxt''_typing, k' |) =
elim_all f mk ctxt'_typing uvs in
progress, (| g', ctxt'', ctxt''_typing, k_elab_trans k k' |) | val add_elims_aux
(#g: env)
(#ctxt #frame: term)
(f: (vprop -> T.Tac bool))
(mk: mk_t)
(ctxt_frame_typing: tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs: env{disjoint uvs g})
: T.Tac
(bool &
(g': env{env_extends g' g /\ disjoint uvs g'} &
ctxt': term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame)))
let add_elims_aux
(#g: env)
(#ctxt #frame: term)
(f: (vprop -> T.Tac bool))
(mk: mk_t)
(ctxt_frame_typing: tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs: env{disjoint uvs g})
: T.Tac
(bool &
(g': env{env_extends g' g /\ disjoint uvs g'} &
ctxt': term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))) = | true | null | false | let (| ctxt' , ctxt'_typing , k |) = canon_right ctxt_frame_typing f in
let progress, (| g' , ctxt'' , ctxt''_typing , k' |) = elim_all f mk ctxt'_typing uvs in
progress, (| g', ctxt'', ctxt''_typing, k_elab_trans k k' |) | {
"checked_file": "Pulse.Checker.Prover.Base.fst.checked",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.VPropEquiv.fsti.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Base.fst"
} | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.vprop",
"Prims.bool",
"Pulse.Checker.Prover.Base.mk_t",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_star",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.Env.disjoint",
"Pulse.Checker.Base.continuation_elaborator",
"Prims.l_and",
"Pulse.Typing.Env.env_extends",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.dtuple4",
"FStar.Pervasives.Mkdtuple4",
"Pulse.Checker.Base.k_elab_trans",
"FStar.Pervasives.Native.tuple2",
"Pulse.Checker.Prover.Base.elim_all",
"FStar.Pervasives.dtuple3",
"Pulse.Checker.Prover.Base.canon_right"
] | [] | module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Base
open Pulse.Typing.Combinators
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs
let rec list_as_vprop' (vp:vprop) (fvps:list vprop)
: Tot vprop (decreases fvps) =
match fvps with
| [] -> vp
| hd::tl -> list_as_vprop' (tm_star vp hd) tl
let rec canon_right_aux (g:env) (vps:list vprop) (f:vprop -> T.Tac bool)
: T.Tac (vps' : list vprop &
fvps : list vprop &
vprop_equiv g (list_as_vprop vps) (list_as_vprop' (list_as_vprop vps') fvps)) =
match vps with
| [] -> (| [], [], VE_Refl _ _ |)
| hd::rest ->
if f hd
then begin
let (| vps', fvps, _ |) = canon_right_aux g rest f in
let v_eq = magic () in
// let v_eq
// : vprop_equiv g (list_as_vprop vps)
// (list_as_vprop (hd :: (vps' @ fvps)))
// = list_as_vprop_ctx g [hd] _ rest (vps' @ fvps) (VE_Refl _ _) v_eq
// in
// let v_eq
// : vprop_equiv g (list_as_vprop vps)
// (list_as_vprop ((vps'@[hd]) @ fvps))
// = VE_Trans _ _ _ _ v_eq (VE_Sym _ _ _ (vprop_equiv_swap_equiv _ _ _ hd _ (VE_Refl _ _)))
// in
// let v_eq
// : vprop_equiv g (list_as_vprop vps)
// (list_as_vprop (vps'@(hd::fvps)))
// = VE_Trans _ _ _ _ v_eq (VE_Sym _ _ _ (list_as_vprop_assoc _ _ _ _)) in
(| vps', hd :: fvps, v_eq |)
end
else begin
let (| vps', pures, _ |) = canon_right_aux g rest f in
let v_eq = magic () in //list_as_vprop_ctx g [hd] _ _ _ (VE_Refl _ _) v_eq in
(| hd::vps', pures, v_eq |)
end
module VP = Pulse.Checker.VPropEquiv
let canon_right (#g:env) (#ctxt:term) (#frame:term)
(ctxt_frame_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(f:vprop -> T.Tac bool)
: T.Tac (ctxt':term &
tot_typing g (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g (tm_star ctxt' frame))
= let (| vps', pures, veq |) = canon_right_aux g (vprop_as_list ctxt) f in
let veq : vprop_equiv g ctxt (list_as_vprop' (list_as_vprop vps') pures)
= magic () in
let veq : vprop_equiv g (tm_star ctxt frame) (tm_star (list_as_vprop' (list_as_vprop vps') pures) frame)
= VE_Ctxt _ _ _ _ _ veq (VE_Refl _ _) in
(| _, VP.vprop_equiv_typing_fwd ctxt_frame_typing veq, k_elab_equiv (k_elab_unit _ _) (VE_Refl _ _) veq |)
let elim_one (#g:env)
(ctxt:term) (frame:vprop) (p:vprop)
(ctxt_frame_p_typing:tot_typing g (tm_star (tm_star ctxt frame) p) tm_vprop)
(nx:ppname) (e1:st_term) (c1:comp { stateful_comp c1 /\ comp_pre c1 == p })
(e1_typing:st_typing g e1 c1)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star (tm_star ctxt frame) p) g' (tm_star ctxt' frame)) =
let ctxt_frame_typing = star_typing_inversion_l ctxt_frame_p_typing in
let x = fresh (push_env g uvs) in
let ppname = mk_ppname_no_range "_pelim" in
let k =
continuation_elaborator_with_bind (tm_star ctxt frame) e1_typing ctxt_frame_p_typing (ppname, x) in
let g' = push_binding g x nx (comp_res c1) in
let ctxt' = tm_star (open_term_nv (comp_post c1) (v_as_nv x)) ctxt in
let veq
: vprop_equiv g' (tm_star (open_term_nv (comp_post c1) (v_as_nv x)) (tm_star ctxt frame))
(tm_star ctxt' frame) = VE_Assoc _ _ _ _ in
let k
: continuation_elaborator
g (tm_star (tm_star ctxt frame) p)
g' (tm_star ctxt' frame) =
k_elab_equiv
#g #g'
#(tm_star (tm_star ctxt frame) p)
#(tm_star (tm_star ctxt frame) p)
#(tm_star (open_term_nv (comp_post c1) (v_as_nv x)) (tm_star ctxt frame))
#(tm_star ctxt' frame)
k (VE_Refl g (tm_star (tm_star ctxt frame) p)) veq in
let ctxt'_frame_typing : tot_typing g' (tm_star ctxt' frame) tm_vprop = magic () in
env_extends_push g x ppname_default (comp_res c1);
(| g', ctxt', ctxt'_frame_typing, k |)
let rec elim_all (#g:env)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(#ctxt:term) (#frame:term) (ctxt_frame_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (bool &
(g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame)))
= match ctxt.t with
| Tm_Star ctxt' p ->
let p_typing =
star_typing_inversion_r #_ #ctxt' #p (star_typing_inversion_l ctxt_frame_typing) in
if f p
then match mk #_ #p p_typing with
| Some (| nx, e1, c1, e1_typing |) ->
let (| g', _, ctxt_typing', k |) =
elim_one ctxt' frame p (magic ()) nx e1 c1 e1_typing uvs in
let k
: continuation_elaborator g (tm_star (tm_star ctxt' frame) p)
g' (tm_star _ frame) = k in
let k
: continuation_elaborator g (tm_star (tm_star ctxt' p) frame)
g' (tm_star _ frame) =
k_elab_equiv k
(magic ()) (VE_Refl _ _) in
let _, (| g'', ctxt'', ctxt_typing'', k' |) =
elim_all #g' f mk ctxt_typing' uvs in
true, (| g'', ctxt'', ctxt_typing'', k_elab_trans k k' |)
| None ->
false, (| g, ctxt, ctxt_frame_typing, k_elab_unit _ _ |)
else begin
false, (| g, ctxt, ctxt_frame_typing, k_elab_unit _ _ |)
end
| _ ->
false, (| g, ctxt, ctxt_frame_typing, k_elab_unit _ _ |)
let add_elims_aux (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_frame_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (bool &
(g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop & | false | false | Pulse.Checker.Prover.Base.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 add_elims_aux
(#g: env)
(#ctxt #frame: term)
(f: (vprop -> T.Tac bool))
(mk: mk_t)
(ctxt_frame_typing: tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs: env{disjoint uvs g})
: T.Tac
(bool &
(g': env{env_extends g' g /\ disjoint uvs g'} &
ctxt': term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))) | [] | Pulse.Checker.Prover.Base.add_elims_aux | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
f: (_: Pulse.Syntax.Base.vprop -> FStar.Tactics.Effect.Tac Prims.bool) ->
mk: Pulse.Checker.Prover.Base.mk_t ->
ctxt_frame_typing:
Pulse.Typing.tot_typing g (Pulse.Syntax.Base.tm_star ctxt frame) Pulse.Syntax.Base.tm_vprop ->
uvs: Pulse.Typing.Env.env{Pulse.Typing.Env.disjoint uvs g}
-> FStar.Tactics.Effect.Tac
(Prims.bool *
FStar.Pervasives.dtuple4 (g':
Pulse.Typing.Env.env
{Pulse.Typing.Env.env_extends g' g /\ Pulse.Typing.Env.disjoint uvs g'})
(fun _ -> Pulse.Syntax.Base.term)
(fun g' ctxt' ->
Pulse.Typing.tot_typing g'
(Pulse.Syntax.Base.tm_star ctxt' frame)
Pulse.Syntax.Base.tm_vprop)
(fun g' ctxt' _ ->
Pulse.Checker.Base.continuation_elaborator g
(Pulse.Syntax.Base.tm_star ctxt frame)
g'
(Pulse.Syntax.Base.tm_star ctxt' frame))) | {
"end_col": 66,
"end_line": 155,
"start_col": 4,
"start_line": 152
} |
FStar.Tactics.Effect.Tac | val add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame)) | [
{
"abbrev": true,
"full_module": "Pulse.Checker.VPropEquiv",
"short_module": "VP"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.Substs",
"short_module": "PS"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_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 add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))
= let progress, res = add_elims_aux f mk ctxt_typing uvs in
if not progress
then res
else (
let (| g', ctxt', ctxt'_typing, k |) = res in
let (| g'', ctxt'', ctxt''_typing, k' |) = add_elims f mk ctxt'_typing uvs in
(| g'', ctxt'', ctxt''_typing, k_elab_trans k k' |)
) | val add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame))
let rec add_elims
(#g: env)
(#ctxt #frame: term)
(f: (vprop -> T.Tac bool))
(mk: mk_t)
(ctxt_typing: tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs: env{disjoint uvs g})
: T.Tac
(g': env{env_extends g' g /\ disjoint uvs g'} &
ctxt': term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame)) = | true | null | false | let progress, res = add_elims_aux f mk ctxt_typing uvs in
if not progress
then res
else
(let (| g' , ctxt' , ctxt'_typing , k |) = res in
let (| g'' , ctxt'' , ctxt''_typing , k' |) = add_elims f mk ctxt'_typing uvs in
(| g'', ctxt'', ctxt''_typing, k_elab_trans k k' |)) | {
"checked_file": "Pulse.Checker.Prover.Base.fst.checked",
"dependencies": [
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.VPropEquiv.fsti.checked",
"Pulse.Checker.Prover.Substs.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Prover.Base.fst"
} | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.vprop",
"Prims.bool",
"Pulse.Checker.Prover.Base.mk_t",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_star",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.Env.disjoint",
"FStar.Pervasives.dtuple4",
"Prims.l_and",
"Pulse.Typing.Env.env_extends",
"Pulse.Checker.Base.continuation_elaborator",
"Prims.op_Negation",
"FStar.Pervasives.Mkdtuple4",
"Pulse.Checker.Base.k_elab_trans",
"Pulse.Checker.Prover.Base.add_elims",
"FStar.Pervasives.Native.tuple2",
"Pulse.Checker.Prover.Base.add_elims_aux"
] | [] | module Pulse.Checker.Prover.Base
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Base
open Pulse.Typing.Combinators
module T = FStar.Tactics.V2
module PS = Pulse.Checker.Prover.Substs
let rec list_as_vprop' (vp:vprop) (fvps:list vprop)
: Tot vprop (decreases fvps) =
match fvps with
| [] -> vp
| hd::tl -> list_as_vprop' (tm_star vp hd) tl
let rec canon_right_aux (g:env) (vps:list vprop) (f:vprop -> T.Tac bool)
: T.Tac (vps' : list vprop &
fvps : list vprop &
vprop_equiv g (list_as_vprop vps) (list_as_vprop' (list_as_vprop vps') fvps)) =
match vps with
| [] -> (| [], [], VE_Refl _ _ |)
| hd::rest ->
if f hd
then begin
let (| vps', fvps, _ |) = canon_right_aux g rest f in
let v_eq = magic () in
// let v_eq
// : vprop_equiv g (list_as_vprop vps)
// (list_as_vprop (hd :: (vps' @ fvps)))
// = list_as_vprop_ctx g [hd] _ rest (vps' @ fvps) (VE_Refl _ _) v_eq
// in
// let v_eq
// : vprop_equiv g (list_as_vprop vps)
// (list_as_vprop ((vps'@[hd]) @ fvps))
// = VE_Trans _ _ _ _ v_eq (VE_Sym _ _ _ (vprop_equiv_swap_equiv _ _ _ hd _ (VE_Refl _ _)))
// in
// let v_eq
// : vprop_equiv g (list_as_vprop vps)
// (list_as_vprop (vps'@(hd::fvps)))
// = VE_Trans _ _ _ _ v_eq (VE_Sym _ _ _ (list_as_vprop_assoc _ _ _ _)) in
(| vps', hd :: fvps, v_eq |)
end
else begin
let (| vps', pures, _ |) = canon_right_aux g rest f in
let v_eq = magic () in //list_as_vprop_ctx g [hd] _ _ _ (VE_Refl _ _) v_eq in
(| hd::vps', pures, v_eq |)
end
module VP = Pulse.Checker.VPropEquiv
let canon_right (#g:env) (#ctxt:term) (#frame:term)
(ctxt_frame_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(f:vprop -> T.Tac bool)
: T.Tac (ctxt':term &
tot_typing g (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g (tm_star ctxt' frame))
= let (| vps', pures, veq |) = canon_right_aux g (vprop_as_list ctxt) f in
let veq : vprop_equiv g ctxt (list_as_vprop' (list_as_vprop vps') pures)
= magic () in
let veq : vprop_equiv g (tm_star ctxt frame) (tm_star (list_as_vprop' (list_as_vprop vps') pures) frame)
= VE_Ctxt _ _ _ _ _ veq (VE_Refl _ _) in
(| _, VP.vprop_equiv_typing_fwd ctxt_frame_typing veq, k_elab_equiv (k_elab_unit _ _) (VE_Refl _ _) veq |)
let elim_one (#g:env)
(ctxt:term) (frame:vprop) (p:vprop)
(ctxt_frame_p_typing:tot_typing g (tm_star (tm_star ctxt frame) p) tm_vprop)
(nx:ppname) (e1:st_term) (c1:comp { stateful_comp c1 /\ comp_pre c1 == p })
(e1_typing:st_typing g e1 c1)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star (tm_star ctxt frame) p) g' (tm_star ctxt' frame)) =
let ctxt_frame_typing = star_typing_inversion_l ctxt_frame_p_typing in
let x = fresh (push_env g uvs) in
let ppname = mk_ppname_no_range "_pelim" in
let k =
continuation_elaborator_with_bind (tm_star ctxt frame) e1_typing ctxt_frame_p_typing (ppname, x) in
let g' = push_binding g x nx (comp_res c1) in
let ctxt' = tm_star (open_term_nv (comp_post c1) (v_as_nv x)) ctxt in
let veq
: vprop_equiv g' (tm_star (open_term_nv (comp_post c1) (v_as_nv x)) (tm_star ctxt frame))
(tm_star ctxt' frame) = VE_Assoc _ _ _ _ in
let k
: continuation_elaborator
g (tm_star (tm_star ctxt frame) p)
g' (tm_star ctxt' frame) =
k_elab_equiv
#g #g'
#(tm_star (tm_star ctxt frame) p)
#(tm_star (tm_star ctxt frame) p)
#(tm_star (open_term_nv (comp_post c1) (v_as_nv x)) (tm_star ctxt frame))
#(tm_star ctxt' frame)
k (VE_Refl g (tm_star (tm_star ctxt frame) p)) veq in
let ctxt'_frame_typing : tot_typing g' (tm_star ctxt' frame) tm_vprop = magic () in
env_extends_push g x ppname_default (comp_res c1);
(| g', ctxt', ctxt'_frame_typing, k |)
let rec elim_all (#g:env)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(#ctxt:term) (#frame:term) (ctxt_frame_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (bool &
(g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame)))
= match ctxt.t with
| Tm_Star ctxt' p ->
let p_typing =
star_typing_inversion_r #_ #ctxt' #p (star_typing_inversion_l ctxt_frame_typing) in
if f p
then match mk #_ #p p_typing with
| Some (| nx, e1, c1, e1_typing |) ->
let (| g', _, ctxt_typing', k |) =
elim_one ctxt' frame p (magic ()) nx e1 c1 e1_typing uvs in
let k
: continuation_elaborator g (tm_star (tm_star ctxt' frame) p)
g' (tm_star _ frame) = k in
let k
: continuation_elaborator g (tm_star (tm_star ctxt' p) frame)
g' (tm_star _ frame) =
k_elab_equiv k
(magic ()) (VE_Refl _ _) in
let _, (| g'', ctxt'', ctxt_typing'', k' |) =
elim_all #g' f mk ctxt_typing' uvs in
true, (| g'', ctxt'', ctxt_typing'', k_elab_trans k k' |)
| None ->
false, (| g, ctxt, ctxt_frame_typing, k_elab_unit _ _ |)
else begin
false, (| g, ctxt, ctxt_frame_typing, k_elab_unit _ _ |)
end
| _ ->
false, (| g, ctxt, ctxt_frame_typing, k_elab_unit _ _ |)
let add_elims_aux (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_frame_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (bool &
(g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame)))
= let (| ctxt', ctxt'_typing, k |) = canon_right ctxt_frame_typing f in
let progress, (| g', ctxt'', ctxt''_typing, k' |) =
elim_all f mk ctxt'_typing uvs in
progress, (| g', ctxt'', ctxt''_typing, k_elab_trans k k' |)
let rec add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop & | false | false | Pulse.Checker.Prover.Base.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 add_elims (#g:env) (#ctxt:term) (#frame:term)
(f:vprop -> T.Tac bool)
(mk:mk_t)
(ctxt_typing:tot_typing g (tm_star ctxt frame) tm_vprop)
(uvs:env { disjoint uvs g })
: T.Tac (g':env { env_extends g' g /\ disjoint uvs g' } &
ctxt':term &
tot_typing g' (tm_star ctxt' frame) tm_vprop &
continuation_elaborator g (tm_star ctxt frame) g' (tm_star ctxt' frame)) | [
"recursion"
] | Pulse.Checker.Prover.Base.add_elims | {
"file_name": "lib/steel/pulse/Pulse.Checker.Prover.Base.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
f: (_: Pulse.Syntax.Base.vprop -> FStar.Tactics.Effect.Tac Prims.bool) ->
mk: Pulse.Checker.Prover.Base.mk_t ->
ctxt_typing:
Pulse.Typing.tot_typing g (Pulse.Syntax.Base.tm_star ctxt frame) Pulse.Syntax.Base.tm_vprop ->
uvs: Pulse.Typing.Env.env{Pulse.Typing.Env.disjoint uvs g}
-> FStar.Tactics.Effect.Tac
(FStar.Pervasives.dtuple4 (g':
Pulse.Typing.Env.env
{Pulse.Typing.Env.env_extends g' g /\ Pulse.Typing.Env.disjoint uvs g'})
(fun _ -> Pulse.Syntax.Base.term)
(fun g' ctxt' ->
Pulse.Typing.tot_typing g'
(Pulse.Syntax.Base.tm_star ctxt' frame)
Pulse.Syntax.Base.tm_vprop)
(fun g' ctxt' _ ->
Pulse.Checker.Base.continuation_elaborator g
(Pulse.Syntax.Base.tm_star ctxt frame)
g'
(Pulse.Syntax.Base.tm_star ctxt' frame))) | {
"end_col": 6,
"end_line": 173,
"start_col": 4,
"start_line": 166
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_fully_reduced5 (f:felem5) =
felem_fits5 f (1,1,1,1,1) /\
as_nat5 f < S.prime | let inv_fully_reduced5 (f: felem5) = | false | null | false | felem_fits5 f (1, 1, 1, 1, 1) /\ as_nat5 f < S.prime | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Prims.l_and",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Spec.K256.PointOps.prime",
"Prims.logical"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract
let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4])
noextract
let as_nat (h:mem) (e:felem) : GTot nat =
as_nat5 (as_felem5 h e)
noextract
let feval (h:mem) (e:felem) : GTot S.felem = as_nat h e % S.prime
noextract | false | true | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_fully_reduced5 : f: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.logical | [] | Hacl.K256.Field.inv_fully_reduced5 | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.logical | {
"end_col": 21,
"end_line": 44,
"start_col": 2,
"start_line": 43
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_lazy_reduced1 (h:mem) (e:felem) =
inv_lazy_reduced1_5 (as_felem5 h e) | let inv_lazy_reduced1 (h: mem) (e: felem) = | false | null | false | inv_lazy_reduced1_5 (as_felem5 h e) | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.K256.Field.felem",
"Hacl.K256.Field.inv_lazy_reduced1_5",
"Hacl.K256.Field.as_felem5",
"Prims.logical"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract
let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4])
noextract
let as_nat (h:mem) (e:felem) : GTot nat =
as_nat5 (as_felem5 h e)
noextract
let feval (h:mem) (e:felem) : GTot S.felem = as_nat h e % S.prime
noextract
let inv_fully_reduced5 (f:felem5) =
felem_fits5 f (1,1,1,1,1) /\
as_nat5 f < S.prime
noextract
let inv_fully_reduced (h:mem) (e:felem) =
inv_fully_reduced5 (as_felem5 h e)
noextract
let inv_lazy_reduced1_5 (f:felem5) =
felem_fits5 f (1,1,1,1,1)
noextract | false | true | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_lazy_reduced1 : h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Field.felem -> Prims.logical | [] | Hacl.K256.Field.inv_lazy_reduced1 | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Field.felem -> Prims.logical | {
"end_col": 37,
"end_line": 57,
"start_col": 2,
"start_line": 57
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let felem = lbuffer uint64 nlimb | let felem = | false | null | false | lbuffer uint64 nlimb | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"total"
] | [
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"Hacl.K256.Field.nlimb"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul | false | true | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val felem : Type0 | [] | Hacl.K256.Field.felem | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 32,
"end_line": 26,
"start_col": 12,
"start_line": 26
} |
|
Prims.GTot | val as_nat (h: mem) (e: felem) : GTot nat | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_nat (h:mem) (e:felem) : GTot nat =
as_nat5 (as_felem5 h e) | val as_nat (h: mem) (e: felem) : GTot nat
let as_nat (h: mem) (e: felem) : GTot nat = | false | null | false | as_nat5 (as_felem5 h e) | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.K256.Field.felem",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Hacl.K256.Field.as_felem5",
"Prims.nat"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract
let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4])
noextract | false | false | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_nat (h: mem) (e: felem) : GTot nat | [] | Hacl.K256.Field.as_nat | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Field.felem -> Prims.GTot Prims.nat | {
"end_col": 25,
"end_line": 36,
"start_col": 2,
"start_line": 36
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_lazy_reduced2 (h:mem) (e:felem) =
inv_lazy_reduced2_5 (as_felem5 h e) | let inv_lazy_reduced2 (h: mem) (e: felem) = | false | null | false | inv_lazy_reduced2_5 (as_felem5 h e) | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.K256.Field.felem",
"Hacl.K256.Field.inv_lazy_reduced2_5",
"Hacl.K256.Field.as_felem5",
"Prims.logical"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract
let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4])
noextract
let as_nat (h:mem) (e:felem) : GTot nat =
as_nat5 (as_felem5 h e)
noextract
let feval (h:mem) (e:felem) : GTot S.felem = as_nat h e % S.prime
noextract
let inv_fully_reduced5 (f:felem5) =
felem_fits5 f (1,1,1,1,1) /\
as_nat5 f < S.prime
noextract
let inv_fully_reduced (h:mem) (e:felem) =
inv_fully_reduced5 (as_felem5 h e)
noextract
let inv_lazy_reduced1_5 (f:felem5) =
felem_fits5 f (1,1,1,1,1)
noextract
let inv_lazy_reduced1 (h:mem) (e:felem) =
inv_lazy_reduced1_5 (as_felem5 h e)
noextract
let inv_lazy_reduced2_5 (f:felem5) =
felem_fits5 f (1,1,1,1,2)
noextract | false | true | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_lazy_reduced2 : h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Field.felem -> Prims.logical | [] | Hacl.K256.Field.inv_lazy_reduced2 | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Field.felem -> Prims.logical | {
"end_col": 37,
"end_line": 65,
"start_col": 2,
"start_line": 65
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_lazy_reduced1_5 (f:felem5) =
felem_fits5 f (1,1,1,1,1) | let inv_lazy_reduced1_5 (f: felem5) = | false | null | false | felem_fits5 f (1, 1, 1, 1, 1) | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.logical"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract
let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4])
noextract
let as_nat (h:mem) (e:felem) : GTot nat =
as_nat5 (as_felem5 h e)
noextract
let feval (h:mem) (e:felem) : GTot S.felem = as_nat h e % S.prime
noextract
let inv_fully_reduced5 (f:felem5) =
felem_fits5 f (1,1,1,1,1) /\
as_nat5 f < S.prime
noextract
let inv_fully_reduced (h:mem) (e:felem) =
inv_fully_reduced5 (as_felem5 h e)
noextract | false | true | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_lazy_reduced1_5 : f: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.logical | [] | Hacl.K256.Field.inv_lazy_reduced1_5 | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.logical | {
"end_col": 27,
"end_line": 53,
"start_col": 2,
"start_line": 53
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_fully_reduced (h:mem) (e:felem) =
inv_fully_reduced5 (as_felem5 h e) | let inv_fully_reduced (h: mem) (e: felem) = | false | null | false | inv_fully_reduced5 (as_felem5 h e) | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"total"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.K256.Field.felem",
"Hacl.K256.Field.inv_fully_reduced5",
"Hacl.K256.Field.as_felem5",
"Prims.logical"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract
let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4])
noextract
let as_nat (h:mem) (e:felem) : GTot nat =
as_nat5 (as_felem5 h e)
noextract
let feval (h:mem) (e:felem) : GTot S.felem = as_nat h e % S.prime
noextract
let inv_fully_reduced5 (f:felem5) =
felem_fits5 f (1,1,1,1,1) /\
as_nat5 f < S.prime
noextract | false | true | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_fully_reduced : h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Field.felem -> Prims.logical | [] | Hacl.K256.Field.inv_fully_reduced | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Field.felem -> Prims.logical | {
"end_col": 36,
"end_line": 48,
"start_col": 2,
"start_line": 48
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let nlimb = 5ul | let nlimb = | false | null | false | 5ul | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"total"
] | [
"FStar.UInt32.__uint_to_t"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *) | false | true | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val nlimb : FStar.UInt32.t | [] | Hacl.K256.Field.nlimb | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | FStar.UInt32.t | {
"end_col": 15,
"end_line": 23,
"start_col": 12,
"start_line": 23
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inv_lazy_reduced2_5 (f:felem5) =
felem_fits5 f (1,1,1,1,2) | let inv_lazy_reduced2_5 (f: felem5) = | false | null | false | felem_fits5 f (1, 1, 1, 1, 2) | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"total"
] | [
"Hacl.Spec.K256.Field52.Definitions.felem5",
"Hacl.Spec.K256.Field52.Definitions.felem_fits5",
"FStar.Pervasives.Native.Mktuple5",
"Prims.nat",
"Prims.logical"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract
let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4])
noextract
let as_nat (h:mem) (e:felem) : GTot nat =
as_nat5 (as_felem5 h e)
noextract
let feval (h:mem) (e:felem) : GTot S.felem = as_nat h e % S.prime
noextract
let inv_fully_reduced5 (f:felem5) =
felem_fits5 f (1,1,1,1,1) /\
as_nat5 f < S.prime
noextract
let inv_fully_reduced (h:mem) (e:felem) =
inv_fully_reduced5 (as_felem5 h e)
noextract
let inv_lazy_reduced1_5 (f:felem5) =
felem_fits5 f (1,1,1,1,1)
noextract
let inv_lazy_reduced1 (h:mem) (e:felem) =
inv_lazy_reduced1_5 (as_felem5 h e)
noextract | false | true | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inv_lazy_reduced2_5 : f: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.logical | [] | Hacl.K256.Field.inv_lazy_reduced2_5 | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.Spec.K256.Field52.Definitions.felem5 -> Prims.logical | {
"end_col": 27,
"end_line": 61,
"start_col": 2,
"start_line": 61
} |
|
Prims.GTot | val feval (h: mem) (e: felem) : GTot S.felem | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let feval (h:mem) (e:felem) : GTot S.felem = as_nat h e % S.prime | val feval (h: mem) (e: felem) : GTot S.felem
let feval (h: mem) (e: felem) : GTot S.felem = | false | null | false | as_nat h e % S.prime | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.K256.Field.felem",
"Prims.op_Modulus",
"Hacl.K256.Field.as_nat",
"Spec.K256.PointOps.prime",
"Spec.K256.PointOps.felem"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract
let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4])
noextract
let as_nat (h:mem) (e:felem) : GTot nat =
as_nat5 (as_felem5 h e) | false | false | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val feval (h: mem) (e: felem) : GTot S.felem | [] | Hacl.K256.Field.feval | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Field.felem -> Prims.GTot Spec.K256.PointOps.felem | {
"end_col": 65,
"end_line": 39,
"start_col": 45,
"start_line": 39
} |
Prims.GTot | val as_felem4 (h: mem) (e: lbuffer uint64 4ul) : GTot felem4 | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_felem4 (h:mem) (e:lbuffer uint64 4ul) : GTot felem4 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[3], s.[2], s.[1], s.[0]) | val as_felem4 (h: mem) (e: lbuffer uint64 4ul) : GTot felem4
let as_felem4 (h: mem) (e: lbuffer uint64 4ul) : GTot felem4 = | false | null | false | let open Lib.Sequence in
let s = as_seq h e in
(s.[ 3 ], s.[ 2 ], s.[ 1 ], s.[ 0 ]) | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.mem",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.Mktuple4",
"Lib.Sequence.op_String_Access",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Spec.K256.Field52.Definitions.felem4"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract
let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4])
noextract
let as_nat (h:mem) (e:felem) : GTot nat =
as_nat5 (as_felem5 h e)
noextract
let feval (h:mem) (e:felem) : GTot S.felem = as_nat h e % S.prime
noextract
let inv_fully_reduced5 (f:felem5) =
felem_fits5 f (1,1,1,1,1) /\
as_nat5 f < S.prime
noextract
let inv_fully_reduced (h:mem) (e:felem) =
inv_fully_reduced5 (as_felem5 h e)
noextract
let inv_lazy_reduced1_5 (f:felem5) =
felem_fits5 f (1,1,1,1,1)
noextract
let inv_lazy_reduced1 (h:mem) (e:felem) =
inv_lazy_reduced1_5 (as_felem5 h e)
noextract
let inv_lazy_reduced2_5 (f:felem5) =
felem_fits5 f (1,1,1,1,2)
noextract
let inv_lazy_reduced2 (h:mem) (e:felem) =
inv_lazy_reduced2_5 (as_felem5 h e)
noextract | false | false | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_felem4 (h: mem) (e: lbuffer uint64 4ul) : GTot felem4 | [] | Hacl.K256.Field.as_felem4 | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> e: Lib.Buffer.lbuffer Lib.IntTypes.uint64 4ul
-> Prims.GTot Hacl.Spec.K256.Field52.Definitions.felem4 | {
"end_col": 30,
"end_line": 72,
"start_col": 2,
"start_line": 70
} |
Prims.GTot | val as_felem5 (h: mem) (e: felem) : GTot felem5 | [
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.Field52",
"short_module": "BI"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.Field52.Definitions",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"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.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let as_felem5 (h:mem) (e:felem) : GTot felem5 =
let open Lib.Sequence in
let s = as_seq h e in
(s.[0], s.[1], s.[2], s.[3], s.[4]) | val as_felem5 (h: mem) (e: felem) : GTot felem5
let as_felem5 (h: mem) (e: felem) : GTot felem5 = | false | null | false | let open Lib.Sequence in
let s = as_seq h e in
(s.[ 0 ], s.[ 1 ], s.[ 2 ], s.[ 3 ], s.[ 4 ]) | {
"checked_file": "Hacl.K256.Field.fsti.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.Field52.Definitions.fst.checked",
"Hacl.Spec.K256.Field52.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.K256.Field.fsti"
} | [
"sometrivial"
] | [
"FStar.Monotonic.HyperStack.mem",
"Hacl.K256.Field.felem",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.uint64",
"Lib.Sequence.op_String_Access",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.K256.Field.nlimb",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Spec.K256.Field52.Definitions.felem5"
] | [] | module Hacl.K256.Field
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 BSeq = Lib.ByteSequence
module S = Spec.K256
include Hacl.Spec.K256.Field52.Definitions
module BI = Hacl.Spec.K256.Field52
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
(** Specialized bignum library with a radix-2^{52} *)
inline_for_extraction noextract
let nlimb = 5ul
inline_for_extraction noextract
let felem = lbuffer uint64 nlimb
noextract | false | false | Hacl.K256.Field.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val as_felem5 (h: mem) (e: felem) : GTot felem5 | [] | Hacl.K256.Field.as_felem5 | {
"file_name": "code/k256/Hacl.K256.Field.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h: FStar.Monotonic.HyperStack.mem -> e: Hacl.K256.Field.felem
-> Prims.GTot Hacl.Spec.K256.Field52.Definitions.felem5 | {
"end_col": 37,
"end_line": 32,
"start_col": 2,
"start_line": 30
} |
Prims.Tot | val round_key_256 (prev0 prev1: quad32) (round: nat) : quad32 | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let round_key_256 (prev0 prev1:quad32) (round:nat) : quad32 =
round_key_256_rcon prev0 prev1 (aes_rcon (round / 2 - 1)) round | val round_key_256 (prev0 prev1: quad32) (round: nat) : quad32
let round_key_256 (prev0 prev1: quad32) (round: nat) : quad32 = | false | null | false | round_key_256_rcon prev0 prev1 (aes_rcon (round / 2 - 1)) round | {
"checked_file": "Vale.AES.AES256_helpers.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES256_helpers.fsti"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Prims.nat",
"Vale.AES.AES256_helpers.round_key_256_rcon",
"Vale.AES.AES_common_s.aes_rcon",
"Prims.op_Subtraction",
"Prims.op_Division"
] | [] | module Vale.AES.AES256_helpers
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Arch.Types
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
let quad32_shl32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour 0 v0 v1 v2
let make_AES256_key (k0 k1:quad32) : Pure (seq nat32)
(requires True)
(ensures fun key -> is_aes_key_LE AES_256 key)
=
append (quad32_to_seq k0) (quad32_to_seq k1)
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent.
let round_key_256_rcon (prev0 prev1:quad32) (rcon:nat32) (round:int) : quad32 =
let Mkfour v0 v1 v2 v3 = prev0 in
let Mkfour _ _ _ v7 = prev1 in
let c1 = if round % 2 = 0 then sub_word (rot_word_LE v7) *^ rcon else sub_word v7 in
let w0 = v0 *^ c1 in
let w1 = v1 *^ w0 in
let w2 = v2 *^ w1 in
let w3 = v3 *^ w2 in
Mkfour w0 w1 w2 w3 | false | true | Vale.AES.AES256_helpers.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val round_key_256 (prev0 prev1: quad32) (round: nat) : quad32 | [] | Vale.AES.AES256_helpers.round_key_256 | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | prev0: Vale.Def.Types_s.quad32 -> prev1: Vale.Def.Types_s.quad32 -> round: Prims.nat
-> Vale.Def.Types_s.quad32 | {
"end_col": 65,
"end_line": 42,
"start_col": 2,
"start_line": 42
} |
Prims.Pure | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let expand_key_256 = opaque_make expand_key_256_def | let expand_key_256 = | false | null | false | opaque_make expand_key_256_def | {
"checked_file": "Vale.AES.AES256_helpers.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES256_helpers.fsti"
} | [] | [
"Vale.Def.Opaque_s.opaque_make",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.nat",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.is_aes_key_LE",
"Vale.AES.AES_common_s.AES_256",
"Prims.l_True",
"Vale.AES.AES256_helpers.expand_key_256_def"
] | [] | module Vale.AES.AES256_helpers
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Arch.Types
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
let quad32_shl32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour 0 v0 v1 v2
let make_AES256_key (k0 k1:quad32) : Pure (seq nat32)
(requires True)
(ensures fun key -> is_aes_key_LE AES_256 key)
=
append (quad32_to_seq k0) (quad32_to_seq k1)
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent.
let round_key_256_rcon (prev0 prev1:quad32) (rcon:nat32) (round:int) : quad32 =
let Mkfour v0 v1 v2 v3 = prev0 in
let Mkfour _ _ _ v7 = prev1 in
let c1 = if round % 2 = 0 then sub_word (rot_word_LE v7) *^ rcon else sub_word v7 in
let w0 = v0 *^ c1 in
let w1 = v1 *^ w0 in
let w2 = v2 *^ w1 in
let w3 = v3 *^ w2 in
Mkfour w0 w1 w2 w3
let round_key_256 (prev0 prev1:quad32) (round:nat) : quad32 =
round_key_256_rcon prev0 prev1 (aes_rcon (round / 2 - 1)) round
let rec expand_key_256_def (key:seq nat32) (round:nat) : Pure quad32
(requires is_aes_key_LE AES_256 key)
(ensures fun _ -> True)
=
if round = 0 then Mkfour key.[0] key.[1] key.[2] key.[3]
else if round = 1 then Mkfour key.[4] key.[5] key.[6] key.[7] | false | false | Vale.AES.AES256_helpers.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val expand_key_256 : key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> round: Prims.nat
-> Prims.Pure Vale.Def.Types_s.quad32 | [] | Vale.AES.AES256_helpers.expand_key_256 | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> round: Prims.nat
-> Prims.Pure Vale.Def.Types_s.quad32 | {
"end_col": 70,
"end_line": 51,
"start_col": 40,
"start_line": 51
} |
|
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let expand_key_256_reveal = opaque_revealer (`%expand_key_256) expand_key_256 expand_key_256_def | let expand_key_256_reveal = | false | null | true | opaque_revealer (`%expand_key_256) expand_key_256 expand_key_256_def | {
"checked_file": "Vale.AES.AES256_helpers.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES256_helpers.fsti"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.nat",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.is_aes_key_LE",
"Vale.AES.AES_common_s.AES_256",
"Prims.l_True",
"Vale.AES.AES256_helpers.expand_key_256",
"Vale.AES.AES256_helpers.expand_key_256_def"
] | [] | module Vale.AES.AES256_helpers
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Arch.Types
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
let quad32_shl32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour 0 v0 v1 v2
let make_AES256_key (k0 k1:quad32) : Pure (seq nat32)
(requires True)
(ensures fun key -> is_aes_key_LE AES_256 key)
=
append (quad32_to_seq k0) (quad32_to_seq k1)
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent.
let round_key_256_rcon (prev0 prev1:quad32) (rcon:nat32) (round:int) : quad32 =
let Mkfour v0 v1 v2 v3 = prev0 in
let Mkfour _ _ _ v7 = prev1 in
let c1 = if round % 2 = 0 then sub_word (rot_word_LE v7) *^ rcon else sub_word v7 in
let w0 = v0 *^ c1 in
let w1 = v1 *^ w0 in
let w2 = v2 *^ w1 in
let w3 = v3 *^ w2 in
Mkfour w0 w1 w2 w3
let round_key_256 (prev0 prev1:quad32) (round:nat) : quad32 =
round_key_256_rcon prev0 prev1 (aes_rcon (round / 2 - 1)) round
let rec expand_key_256_def (key:seq nat32) (round:nat) : Pure quad32
(requires is_aes_key_LE AES_256 key)
(ensures fun _ -> True)
=
if round = 0 then Mkfour key.[0] key.[1] key.[2] key.[3]
else if round = 1 then Mkfour key.[4] key.[5] key.[6] key.[7]
else round_key_256 (expand_key_256_def key (round - 2)) (expand_key_256_def key (round - 1)) round | false | false | Vale.AES.AES256_helpers.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val expand_key_256_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.AES256_helpers.expand_key_256 == Vale.AES.AES256_helpers.expand_key_256_def) | [] | Vale.AES.AES256_helpers.expand_key_256_reveal | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.AES256_helpers.expand_key_256 == Vale.AES.AES256_helpers.expand_key_256_def) | {
"end_col": 108,
"end_line": 52,
"start_col": 40,
"start_line": 52
} |
|
Prims.Tot | val quad32_shl32 (q: quad32) : quad32 | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let quad32_shl32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour 0 v0 v1 v2 | val quad32_shl32 (q: quad32) : quad32
let quad32_shl32 (q: quad32) : quad32 = | false | null | false | let Mkfour v0 v1 v2 v3 = q in
Mkfour 0 v0 v1 v2 | {
"checked_file": "Vale.AES.AES256_helpers.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES256_helpers.fsti"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.nat32",
"Vale.Def.Words_s.Mkfour"
] | [] | module Vale.AES.AES256_helpers
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Arch.Types
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor | false | true | Vale.AES.AES256_helpers.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val quad32_shl32 (q: quad32) : quad32 | [] | Vale.AES.AES256_helpers.quad32_shl32 | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | q: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32 | {
"end_col": 19,
"end_line": 20,
"start_col": 38,
"start_line": 18
} |
Prims.Tot | val op_String_Access (#a: Type) (s: seq a) (i: nat{i < length s}) : Tot a | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i | val op_String_Access (#a: Type) (s: seq a) (i: nat{i < length s}) : Tot a
let op_String_Access (#a: Type) (s: seq a) (i: nat{i < length s}) : Tot a = | false | null | false | index s i | {
"checked_file": "Vale.AES.AES256_helpers.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES256_helpers.fsti"
} | [
"total"
] | [
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"FStar.Seq.Base.index"
] | [] | module Vale.AES.AES256_helpers
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Arch.Types
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s | false | false | Vale.AES.AES256_helpers.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val op_String_Access (#a: Type) (s: seq a) (i: nat{i < length s}) : Tot a | [] | Vale.AES.AES256_helpers.op_String_Access | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | s: FStar.Seq.Base.seq a -> i: Prims.nat{i < FStar.Seq.Base.length s} -> a | {
"end_col": 79,
"end_line": 12,
"start_col": 70,
"start_line": 12
} |
Prims.Tot | val round_key_256_rcon (prev0 prev1: quad32) (rcon: nat32) (round: int) : quad32 | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let round_key_256_rcon (prev0 prev1:quad32) (rcon:nat32) (round:int) : quad32 =
let Mkfour v0 v1 v2 v3 = prev0 in
let Mkfour _ _ _ v7 = prev1 in
let c1 = if round % 2 = 0 then sub_word (rot_word_LE v7) *^ rcon else sub_word v7 in
let w0 = v0 *^ c1 in
let w1 = v1 *^ w0 in
let w2 = v2 *^ w1 in
let w3 = v3 *^ w2 in
Mkfour w0 w1 w2 w3 | val round_key_256_rcon (prev0 prev1: quad32) (rcon: nat32) (round: int) : quad32
let round_key_256_rcon (prev0 prev1: quad32) (rcon: nat32) (round: int) : quad32 = | false | null | false | let Mkfour v0 v1 v2 v3 = prev0 in
let Mkfour _ _ _ v7 = prev1 in
let c1 = if round % 2 = 0 then sub_word (rot_word_LE v7) *^ rcon else sub_word v7 in
let w0 = v0 *^ c1 in
let w1 = v1 *^ w0 in
let w2 = v2 *^ w1 in
let w3 = v3 *^ w2 in
Mkfour w0 w1 w2 w3 | {
"checked_file": "Vale.AES.AES256_helpers.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES256_helpers.fsti"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.nat32",
"Prims.int",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words_s.nat32",
"Vale.AES.AES256_helpers.op_Star_Hat",
"Prims.op_Equality",
"Prims.op_Modulus",
"Vale.AES.AES_common_s.sub_word",
"Vale.AES.AES_s.rot_word_LE",
"Prims.bool"
] | [] | module Vale.AES.AES256_helpers
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Arch.Types
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
let quad32_shl32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour 0 v0 v1 v2
let make_AES256_key (k0 k1:quad32) : Pure (seq nat32)
(requires True)
(ensures fun key -> is_aes_key_LE AES_256 key)
=
append (quad32_to_seq k0) (quad32_to_seq k1)
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent. | false | true | Vale.AES.AES256_helpers.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val round_key_256_rcon (prev0 prev1: quad32) (rcon: nat32) (round: int) : quad32 | [] | Vale.AES.AES256_helpers.round_key_256_rcon | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
prev0: Vale.Def.Types_s.quad32 ->
prev1: Vale.Def.Types_s.quad32 ->
rcon: Vale.Def.Types_s.nat32 ->
round: Prims.int
-> Vale.Def.Types_s.quad32 | {
"end_col": 20,
"end_line": 39,
"start_col": 79,
"start_line": 31
} |
Prims.Tot | val simd_round_key_256 (prev0 prev1: quad32) (rcon: nat32) (round: int) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let simd_round_key_256 (prev0 prev1:quad32) (rcon:nat32) (round:int) : quad32 =
let r = if round % 2 = 0 then rot_word_LE (sub_word prev1.hi3) *^ rcon else sub_word prev1.hi3 in
let q = prev0 in
let q = q *^^ quad32_shl32 q in
let q = q *^^ quad32_shl32 q in
let q = q *^^ quad32_shl32 q in
q *^^ Mkfour r r r r | val simd_round_key_256 (prev0 prev1: quad32) (rcon: nat32) (round: int) : quad32
let simd_round_key_256 (prev0 prev1: quad32) (rcon: nat32) (round: int) : quad32 = | false | null | false | let r = if round % 2 = 0 then rot_word_LE (sub_word prev1.hi3) *^ rcon else sub_word prev1.hi3 in
let q = prev0 in
let q = q *^^ quad32_shl32 q in
let q = q *^^ quad32_shl32 q in
let q = q *^^ quad32_shl32 q in
q *^^ Mkfour r r r r | {
"checked_file": "Vale.AES.AES256_helpers.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES256_helpers.fsti"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.nat32",
"Prims.int",
"Vale.AES.AES256_helpers.op_Star_Hat_Hat",
"Vale.Def.Words_s.Mkfour",
"Vale.AES.AES256_helpers.quad32_shl32",
"Vale.Def.Words_s.nat32",
"Prims.op_Equality",
"Prims.op_Modulus",
"Vale.AES.AES256_helpers.op_Star_Hat",
"Vale.AES.AES_s.rot_word_LE",
"Vale.AES.AES_common_s.sub_word",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Prims.bool"
] | [] | module Vale.AES.AES256_helpers
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Arch.Types
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
let quad32_shl32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour 0 v0 v1 v2
let make_AES256_key (k0 k1:quad32) : Pure (seq nat32)
(requires True)
(ensures fun key -> is_aes_key_LE AES_256 key)
=
append (quad32_to_seq k0) (quad32_to_seq k1)
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent.
let round_key_256_rcon (prev0 prev1:quad32) (rcon:nat32) (round:int) : quad32 =
let Mkfour v0 v1 v2 v3 = prev0 in
let Mkfour _ _ _ v7 = prev1 in
let c1 = if round % 2 = 0 then sub_word (rot_word_LE v7) *^ rcon else sub_word v7 in
let w0 = v0 *^ c1 in
let w1 = v1 *^ w0 in
let w2 = v2 *^ w1 in
let w3 = v3 *^ w2 in
Mkfour w0 w1 w2 w3
let round_key_256 (prev0 prev1:quad32) (round:nat) : quad32 =
round_key_256_rcon prev0 prev1 (aes_rcon (round / 2 - 1)) round
let rec expand_key_256_def (key:seq nat32) (round:nat) : Pure quad32
(requires is_aes_key_LE AES_256 key)
(ensures fun _ -> True)
=
if round = 0 then Mkfour key.[0] key.[1] key.[2] key.[3]
else if round = 1 then Mkfour key.[4] key.[5] key.[6] key.[7]
else round_key_256 (expand_key_256_def key (round - 2)) (expand_key_256_def key (round - 1)) round
[@"opaque_to_smt"] let expand_key_256 = opaque_make expand_key_256_def
irreducible let expand_key_256_reveal = opaque_revealer (`%expand_key_256) expand_key_256 expand_key_256_def
// quad32 key expansion is equivalent to nat32 key expansion
val lemma_expand_key_256 (key:seq nat32) (size:nat) : Lemma
(requires size <= 15 /\ is_aes_key_LE AES_256 key)
(ensures (
let s = key_schedule_to_round_keys size (expand_key AES_256 key 60) in
(forall (i:nat).{:pattern (expand_key_256 key i)} i < size ==> expand_key_256 key i == s.[i])
)) | false | true | Vale.AES.AES256_helpers.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val simd_round_key_256 (prev0 prev1: quad32) (rcon: nat32) (round: int) : quad32 | [] | Vale.AES.AES256_helpers.simd_round_key_256 | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
prev0: Vale.Def.Types_s.quad32 ->
prev1: Vale.Def.Types_s.quad32 ->
rcon: Vale.Def.Types_s.nat32 ->
round: Prims.int
-> Vale.Def.Types_s.quad32 | {
"end_col": 22,
"end_line": 69,
"start_col": 79,
"start_line": 63
} |
Prims.Pure | val make_AES256_key (k0 k1: quad32)
: Pure (seq nat32) (requires True) (ensures fun key -> is_aes_key_LE AES_256 key) | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let make_AES256_key (k0 k1:quad32) : Pure (seq nat32)
(requires True)
(ensures fun key -> is_aes_key_LE AES_256 key)
=
append (quad32_to_seq k0) (quad32_to_seq k1) | val make_AES256_key (k0 k1: quad32)
: Pure (seq nat32) (requires True) (ensures fun key -> is_aes_key_LE AES_256 key)
let make_AES256_key (k0 k1: quad32)
: Pure (seq nat32) (requires True) (ensures fun key -> is_aes_key_LE AES_256 key) = | false | null | false | append (quad32_to_seq k0) (quad32_to_seq k1) | {
"checked_file": "Vale.AES.AES256_helpers.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES256_helpers.fsti"
} | [] | [
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.append",
"Vale.Def.Words_s.nat32",
"Vale.Arch.Types.quad32_to_seq",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.l_True",
"Vale.AES.AES_s.is_aes_key_LE",
"Vale.AES.AES_common_s.AES_256"
] | [] | module Vale.AES.AES256_helpers
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Arch.Types
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
let quad32_shl32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour 0 v0 v1 v2
let make_AES256_key (k0 k1:quad32) : Pure (seq nat32)
(requires True)
(ensures fun key -> is_aes_key_LE AES_256 key) | false | false | Vale.AES.AES256_helpers.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val make_AES256_key (k0 k1: quad32)
: Pure (seq nat32) (requires True) (ensures fun key -> is_aes_key_LE AES_256 key) | [] | Vale.AES.AES256_helpers.make_AES256_key | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k0: Vale.Def.Types_s.quad32 -> k1: Vale.Def.Types_s.quad32
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat32) | {
"end_col": 46,
"end_line": 26,
"start_col": 2,
"start_line": 26
} |
Prims.Pure | val expand_key_256_def (key: seq nat32) (round: nat)
: Pure quad32 (requires is_aes_key_LE AES_256 key) (ensures fun _ -> True) | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec expand_key_256_def (key:seq nat32) (round:nat) : Pure quad32
(requires is_aes_key_LE AES_256 key)
(ensures fun _ -> True)
=
if round = 0 then Mkfour key.[0] key.[1] key.[2] key.[3]
else if round = 1 then Mkfour key.[4] key.[5] key.[6] key.[7]
else round_key_256 (expand_key_256_def key (round - 2)) (expand_key_256_def key (round - 1)) round | val expand_key_256_def (key: seq nat32) (round: nat)
: Pure quad32 (requires is_aes_key_LE AES_256 key) (ensures fun _ -> True)
let rec expand_key_256_def (key: seq nat32) (round: nat)
: Pure quad32 (requires is_aes_key_LE AES_256 key) (ensures fun _ -> True) = | false | null | false | if round = 0
then Mkfour key.[ 0 ] key.[ 1 ] key.[ 2 ] key.[ 3 ]
else
if round = 1
then Mkfour key.[ 4 ] key.[ 5 ] key.[ 6 ] key.[ 7 ]
else round_key_256 (expand_key_256_def key (round - 2)) (expand_key_256_def key (round - 1)) round | {
"checked_file": "Vale.AES.AES256_helpers.fsti.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.AES256_helpers.fsti"
} | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.nat",
"Prims.op_Equality",
"Prims.int",
"Vale.Def.Words_s.Mkfour",
"Vale.AES.AES256_helpers.op_String_Access",
"Prims.bool",
"Vale.AES.AES256_helpers.round_key_256",
"Vale.AES.AES256_helpers.expand_key_256_def",
"Prims.op_Subtraction",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.is_aes_key_LE",
"Vale.AES.AES_common_s.AES_256",
"Prims.l_True"
] | [] | module Vale.AES.AES256_helpers
open FStar.Mul
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Arch.Types
open Vale.Def.Types_s
open FStar.Seq
open Vale.AES.AES_s
// syntax for seq accesses, s.[index] and s.[index] <- value
unfold let (.[]) (#a:Type) (s:seq a) (i:nat{ i < length s}) : Tot a = index s i
unfold let (.[]<-) = Seq.upd
unfold let ( *^ ) = nat32_xor
unfold let ( *^^ ) = quad32_xor
let quad32_shl32 (q:quad32) : quad32 =
let Mkfour v0 v1 v2 v3 = q in
Mkfour 0 v0 v1 v2
let make_AES256_key (k0 k1:quad32) : Pure (seq nat32)
(requires True)
(ensures fun key -> is_aes_key_LE AES_256 key)
=
append (quad32_to_seq k0) (quad32_to_seq k1)
// Redefine key expansion in terms of quad32 values rather than nat32 values,
// then prove both definitions are equivalent.
let round_key_256_rcon (prev0 prev1:quad32) (rcon:nat32) (round:int) : quad32 =
let Mkfour v0 v1 v2 v3 = prev0 in
let Mkfour _ _ _ v7 = prev1 in
let c1 = if round % 2 = 0 then sub_word (rot_word_LE v7) *^ rcon else sub_word v7 in
let w0 = v0 *^ c1 in
let w1 = v1 *^ w0 in
let w2 = v2 *^ w1 in
let w3 = v3 *^ w2 in
Mkfour w0 w1 w2 w3
let round_key_256 (prev0 prev1:quad32) (round:nat) : quad32 =
round_key_256_rcon prev0 prev1 (aes_rcon (round / 2 - 1)) round
let rec expand_key_256_def (key:seq nat32) (round:nat) : Pure quad32
(requires is_aes_key_LE AES_256 key)
(ensures fun _ -> True) | false | false | Vale.AES.AES256_helpers.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val expand_key_256_def (key: seq nat32) (round: nat)
: Pure quad32 (requires is_aes_key_LE AES_256 key) (ensures fun _ -> True) | [
"recursion"
] | Vale.AES.AES256_helpers.expand_key_256_def | {
"file_name": "vale/code/crypto/aes/Vale.AES.AES256_helpers.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 -> round: Prims.nat
-> Prims.Pure Vale.Def.Types_s.quad32 | {
"end_col": 100,
"end_line": 50,
"start_col": 2,
"start_line": 48
} |
Prims.Tot | val return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n | val return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
let return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) = | false | null | false | fun (_, n) -> x, n | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.Pervasives.Native.tuple2",
"FStar.NMSTTotal.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.NMSTTotal.repr",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) | false | false | FStar.NMSTTotal.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 return (a: Type) (x: a) (state: Type u#2) (rel: P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1) | [] | FStar.NMSTTotal.return | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Type -> x: a -> state: Type -> rel: FStar.Preorder.preorder state
-> FStar.NMSTTotal.repr a state rel (fun _ -> Prims.l_True) (fun s0 r s1 -> r == x /\ s0 == s1) | {
"end_col": 20,
"end_line": 42,
"start_col": 2,
"start_line": 42
} |
Prims.Pure | val subcomp
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: M.pre_t state)
(ens_g: M.post_t state a)
(f: repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f | val subcomp
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: M.pre_t state)
(ens_g: M.post_t state a)
(f: repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
let subcomp
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: M.pre_t state)
(ens_g: M.post_t state a)
(f: repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True) = | false | null | false | f | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [] | [
"FStar.Preorder.preorder",
"FStar.MSTTotal.pre_t",
"FStar.MSTTotal.post_t",
"FStar.NMSTTotal.repr",
"Prims.l_and",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_True"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True) | false | false | FStar.NMSTTotal.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 subcomp
(a: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: M.pre_t state)
(ens_g: M.post_t state a)
(f: repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True) | [] | FStar.NMSTTotal.subcomp | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
a: Type ->
state: Type ->
rel: FStar.Preorder.preorder state ->
req_f: FStar.MSTTotal.pre_t state ->
ens_f: FStar.MSTTotal.post_t state a ->
req_g: FStar.MSTTotal.pre_t state ->
ens_g: FStar.MSTTotal.post_t state a ->
f: FStar.NMSTTotal.repr a state rel req_f ens_f
-> Prims.Pure (FStar.NMSTTotal.repr a state rel req_g ens_g) | {
"end_col": 3,
"end_line": 78,
"start_col": 2,
"start_line": 78
} |
FStar.NMSTTotal.NMSTATETOT | val sample: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATETOT bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 sample (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT bool state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATETOT?.reflect (fun (t, n) -> t n, n+1) | val sample: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATETOT bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1)
let sample (#state: Type u#2) (#rel: P.preorder state) ()
: NMSTATETOT bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) = | true | null | false | NMSTATETOT?.reflect (fun (t, n) -> t n, n + 1) | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [] | [
"FStar.Preorder.preorder",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"FStar.NMSTTotal.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Prims.op_Addition",
"Prims.l_True",
"Prims.eq2"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
total
reflectable
effect {
NMSTATETOT (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATETOT unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> M.witness state rel p, n)
[@@ noextract_to "krml"]
let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATETOT unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1)
=
NMSTATETOT?.reflect (fun (_, n) -> M.recall state rel p w, n)
[@@ noextract_to "krml"]
let sample (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT bool state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1) | false | false | FStar.NMSTTotal.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 sample: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATETOT bool state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1) | [] | FStar.NMSTTotal.sample | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: Prims.unit -> FStar.NMSTTotal.NMSTATETOT Prims.bool | {
"end_col": 46,
"end_line": 151,
"start_col": 2,
"start_line": 151
} |
FStar.NMSTTotal.NMSTATETOT | val get: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATETOT state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.get (), n) | val get: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATETOT state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1)
let get (#state: Type u#2) (#rel: P.preorder state) ()
: NMSTATETOT state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) = | true | null | false | NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.get (), n) | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [] | [
"FStar.Preorder.preorder",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"FStar.NMSTTotal.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.MSTTotal.get",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
total
reflectable
effect {
NMSTATETOT (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1) | false | false | FStar.NMSTTotal.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get: #state: Type u#2 -> #rel: P.preorder state -> Prims.unit
-> NMSTATETOT state state rel (fun _ -> True) (fun s0 s s1 -> s0 == s /\ s == s1) | [] | FStar.NMSTTotal.get | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | _: Prims.unit -> FStar.NMSTTotal.NMSTATETOT state | {
"end_col": 56,
"end_line": 115,
"start_col": 2,
"start_line": 115
} |
Prims.Tot | val lift_pure_nmst
(a: Type)
(wp: pure_wp a)
(state: Type u#2)
(rel: P.preorder state)
(f: (eqtype_as_type unit -> PURE a wp))
: repr a
state
rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~(wp (fun r -> r =!= x \/ s0 =!= s1)))) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 lift_pure_nmst
(a:Type)
(wp:pure_wp a)
(state:Type u#2)
(rel:P.preorder state)
(f:eqtype_as_type unit -> PURE a wp)
: repr a state rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~ (wp (fun r -> r =!= x \/ s0 =!= s1))))
=
fun (_, n) ->
elim_pure_wp_monotonicity wp;
let x = f () in
x, n | val lift_pure_nmst
(a: Type)
(wp: pure_wp a)
(state: Type u#2)
(rel: P.preorder state)
(f: (eqtype_as_type unit -> PURE a wp))
: repr a
state
rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~(wp (fun r -> r =!= x \/ s0 =!= s1))))
let lift_pure_nmst
(a: Type)
(wp: pure_wp a)
(state: Type u#2)
(rel: P.preorder state)
(f: (eqtype_as_type unit -> PURE a wp))
: repr a
state
rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~(wp (fun r -> r =!= x \/ s0 =!= s1)))) = | false | null | false | fun (_, n) ->
elim_pure_wp_monotonicity wp;
let x = f () in
x, n | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [
"total"
] | [
"Prims.pure_wp",
"FStar.Preorder.preorder",
"FStar.Pervasives.eqtype_as_type",
"Prims.unit",
"FStar.Pervasives.Native.tuple2",
"FStar.NMSTTotal.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Monotonic.Pure.elim_pure_wp_monotonicity",
"FStar.NMSTTotal.repr",
"Prims.l_True",
"Prims.l_and",
"Prims.l_not",
"Prims.l_or",
"Prims.eq2"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
total
reflectable
effect {
NMSTATETOT (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATETOT unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> M.witness state rel p, n)
[@@ noextract_to "krml"]
let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATETOT unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1)
=
NMSTATETOT?.reflect (fun (_, n) -> M.recall state rel p w, n)
[@@ noextract_to "krml"]
let sample (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT bool state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATETOT?.reflect (fun (t, n) -> t n, n+1)
let lift_pure_nmst
(a:Type)
(wp:pure_wp a)
(state:Type u#2)
(rel:P.preorder state)
(f:eqtype_as_type unit -> PURE a wp)
: repr a state rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~ (wp (fun r -> r =!= x \/ s0 =!= s1)))) | false | false | FStar.NMSTTotal.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 lift_pure_nmst
(a: Type)
(wp: pure_wp a)
(state: Type u#2)
(rel: P.preorder state)
(f: (eqtype_as_type unit -> PURE a wp))
: repr a
state
rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~(wp (fun r -> r =!= x \/ s0 =!= s1)))) | [] | FStar.NMSTTotal.lift_pure_nmst | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
a: Type ->
wp: Prims.pure_wp a ->
state: Type ->
rel: FStar.Preorder.preorder state ->
f: (_: FStar.Pervasives.eqtype_as_type Prims.unit -> Prims.PURE a)
-> FStar.NMSTTotal.repr a
state
rel
(fun _ -> wp (fun _ -> Prims.l_True))
(fun s0 x s1 -> wp (fun _ -> Prims.l_True) /\ ~(wp (fun r -> ~(r == x) \/ ~(s0 == s1)))) | {
"end_col": 8,
"end_line": 166,
"start_col": 2,
"start_line": 163
} |
FStar.NMSTTotal.NMSTATETOT | val nmst_tot_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type)
: NMSTATETOT unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 nmst_tot_assert (#state:Type u#2) (#rel:P.preorder state) (p:Type)
: NMSTATETOT unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1)
=
assert p | val nmst_tot_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type)
: NMSTATETOT unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1)
let nmst_tot_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type)
: NMSTATETOT unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) = | true | null | false | assert p | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [] | [
"FStar.Preorder.preorder",
"Prims._assert",
"Prims.unit",
"Prims.l_and",
"Prims.eq2"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
total
reflectable
effect {
NMSTATETOT (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATETOT unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> M.witness state rel p, n)
[@@ noextract_to "krml"]
let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATETOT unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1)
=
NMSTATETOT?.reflect (fun (_, n) -> M.recall state rel p w, n)
[@@ noextract_to "krml"]
let sample (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT bool state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATETOT?.reflect (fun (t, n) -> t n, n+1)
let lift_pure_nmst
(a:Type)
(wp:pure_wp a)
(state:Type u#2)
(rel:P.preorder state)
(f:eqtype_as_type unit -> PURE a wp)
: repr a state rel
(fun s0 -> wp (fun _ -> True))
(fun s0 x s1 -> wp (fun _ -> True) /\ (~ (wp (fun r -> r =!= x \/ s0 =!= s1))))
=
fun (_, n) ->
elim_pure_wp_monotonicity wp;
let x = f () in
x, n
sub_effect PURE ~> NMSTATETOT = lift_pure_nmst
let nmst_tot_assume (#state:Type u#2) (#rel:P.preorder state) (p:Type)
: NMSTATETOT unit state rel (fun _ -> True) (fun m0 _ m1 -> p /\ m0 == m1)
=
assume p
let nmst_tot_admit (#state:Type u#2) (#rel:P.preorder state) (#a:Type) ()
: NMSTATETOT a state rel (fun _ -> True) (fun _ _ _ -> False)
=
admit ()
let nmst_tot_assert (#state:Type u#2) (#rel:P.preorder state) (p:Type)
: NMSTATETOT unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) | false | false | FStar.NMSTTotal.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 nmst_tot_assert (#state: Type u#2) (#rel: P.preorder state) (p: Type)
: NMSTATETOT unit state rel (fun _ -> p) (fun m0 _ m1 -> p /\ m0 == m1) | [] | FStar.NMSTTotal.nmst_tot_assert | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: Type0 -> FStar.NMSTTotal.NMSTATETOT Prims.unit | {
"end_col": 10,
"end_line": 183,
"start_col": 2,
"start_line": 183
} |
FStar.NMSTTotal.NMSTATETOT | val recall
(state: Type u#2)
(rel: P.preorder state)
(p: W.s_predicate state)
(w: W.witnessed state rel p)
: NMSTATETOT unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATETOT unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1)
=
NMSTATETOT?.reflect (fun (_, n) -> M.recall state rel p w, n) | val recall
(state: Type u#2)
(rel: P.preorder state)
(p: W.s_predicate state)
(w: W.witnessed state rel p)
: NMSTATETOT unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1)
let recall
(state: Type u#2)
(rel: P.preorder state)
(p: W.s_predicate state)
(w: W.witnessed state rel p)
: NMSTATETOT unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) = | true | null | false | NMSTATETOT?.reflect (fun (_, n) -> M.recall state rel p w, n) | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [] | [
"FStar.Preorder.preorder",
"FStar.Witnessed.Core.s_predicate",
"FStar.Witnessed.Core.witnessed",
"FStar.Pervasives.Native.tuple2",
"FStar.NMSTTotal.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"FStar.MSTTotal.recall",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
total
reflectable
effect {
NMSTATETOT (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATETOT unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> M.witness state rel p, n)
[@@ noextract_to "krml"]
let recall (state:Type u#2)
(rel:P.preorder state)
(p:W.s_predicate state)
(w:W.witnessed state rel p)
: NMSTATETOT unit state rel
(fun _ -> True)
(fun s0 _ s1 -> s0 == s1 /\ p s1) | false | false | FStar.NMSTTotal.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val recall
(state: Type u#2)
(rel: P.preorder state)
(p: W.s_predicate state)
(w: W.witnessed state rel p)
: NMSTATETOT unit state rel (fun _ -> True) (fun s0 _ s1 -> s0 == s1 /\ p s1) | [] | FStar.NMSTTotal.recall | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
state: Type ->
rel: FStar.Preorder.preorder state ->
p: FStar.Witnessed.Core.s_predicate state ->
w: FStar.Witnessed.Core.witnessed state rel p
-> FStar.NMSTTotal.NMSTATETOT Prims.unit | {
"end_col": 63,
"end_line": 143,
"start_col": 2,
"start_line": 143
} |
FStar.NMSTTotal.NMSTATETOT | val witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p)
state
rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> M.witness state rel p, n) | val witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p)
state
rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1)
let witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p)
state
rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1) = | true | null | false | NMSTATETOT?.reflect (fun (_, n) -> M.witness state rel p, n) | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [] | [
"FStar.Preorder.preorder",
"FStar.Witnessed.Core.s_predicate",
"FStar.Pervasives.Native.tuple2",
"FStar.NMSTTotal.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Witnessed.Core.witnessed",
"FStar.MSTTotal.witness",
"Prims.l_and",
"FStar.Witnessed.Core.stable",
"Prims.eq2"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
total
reflectable
effect {
NMSTATETOT (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATETOT unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.put s, n)
[@@ noextract_to "krml"]
let witness (state:Type u#2) (rel:P.preorder state) (p:W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p) state rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1) | false | false | FStar.NMSTTotal.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val witness (state: Type u#2) (rel: P.preorder state) (p: W.s_predicate state)
: NMSTATETOT (W.witnessed state rel p)
state
rel
(fun s0 -> p s0 /\ W.stable state rel p)
(fun s0 _ s1 -> s0 == s1) | [] | FStar.NMSTTotal.witness | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | state: Type -> rel: FStar.Preorder.preorder state -> p: FStar.Witnessed.Core.s_predicate state
-> FStar.NMSTTotal.NMSTATETOT (FStar.Witnessed.Core.witnessed state rel p) | {
"end_col": 62,
"end_line": 132,
"start_col": 2,
"start_line": 132
} |
Prims.Tot | val bind
(a b: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: (a -> M.pre_t state))
(ens_g: (a -> M.post_t state b))
(f: repr a state rel req_f ens_f)
(g: (x: a -> repr b state rel (req_g x) (ens_g x)))
: repr b
state
rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1) | val bind
(a b: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: (a -> M.pre_t state))
(ens_g: (a -> M.post_t state b))
(f: repr a state rel req_f ens_f)
(g: (x: a -> repr b state rel (req_g x) (ens_g x)))
: repr b
state
rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
let bind
(a b: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: (a -> M.pre_t state))
(ens_g: (a -> M.post_t state b))
(f: repr a state rel req_f ens_f)
(g: (x: a -> repr b state rel (req_g x) (ens_g x)))
: repr b
state
rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) = | false | null | false | fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1) | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [
"total"
] | [
"FStar.Preorder.preorder",
"FStar.MSTTotal.pre_t",
"FStar.MSTTotal.post_t",
"FStar.NMSTTotal.repr",
"FStar.Pervasives.Native.tuple2",
"FStar.NMSTTotal.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.l_and",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.l_Exists"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) | false | false | FStar.NMSTTotal.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 bind
(a b: Type)
(state: Type u#2)
(rel: P.preorder state)
(req_f: M.pre_t state)
(ens_f: M.post_t state a)
(req_g: (a -> M.pre_t state))
(ens_g: (a -> M.post_t state b))
(f: repr a state rel req_f ens_f)
(g: (x: a -> repr b state rel (req_g x) (ens_g x)))
: repr b
state
rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2)) | [] | FStar.NMSTTotal.bind | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
a: Type ->
b: Type ->
state: Type ->
rel: FStar.Preorder.preorder state ->
req_f: FStar.MSTTotal.pre_t state ->
ens_f: FStar.MSTTotal.post_t state a ->
req_g: (_: a -> FStar.MSTTotal.pre_t state) ->
ens_g: (_: a -> FStar.MSTTotal.post_t state b) ->
f: FStar.NMSTTotal.repr a state rel req_f ens_f ->
g: (x: a -> FStar.NMSTTotal.repr b state rel (req_g x) (ens_g x))
-> FStar.NMSTTotal.repr b
state
rel
(fun s0 -> req_f s0 /\ (forall (x: a) (s1: state). ens_f s0 x s1 ==> req_g x s1))
(fun s0 r s2 ->
req_f s0 /\ (exists (x: a) (s1: state). ens_f s0 x s1 /\ req_g x s1 /\ ens_g x s1 r s2)) | {
"end_col": 17,
"end_line": 61,
"start_col": 2,
"start_line": 59
} |
FStar.NMSTTotal.NMSTATETOT | val put (#state: Type u#2) (#rel: P.preorder state) (s: state)
: NMSTATETOT unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.MSTTotal",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.Witnessed.Core",
"short_module": "W"
},
{
"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 put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATETOT unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.put s, n) | val put (#state: Type u#2) (#rel: P.preorder state) (s: state)
: NMSTATETOT unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s)
let put (#state: Type u#2) (#rel: P.preorder state) (s: state)
: NMSTATETOT unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) = | true | null | false | NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.put s, n) | {
"checked_file": "FStar.NMSTTotal.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Witnessed.Core.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.MSTTotal.fst.checked",
"FStar.Monotonic.Pure.fst.checked"
],
"interface_file": false,
"source_file": "FStar.NMSTTotal.fst"
} | [] | [
"FStar.Preorder.preorder",
"FStar.Pervasives.Native.tuple2",
"FStar.NMSTTotal.tape",
"Prims.nat",
"FStar.Pervasives.Native.Mktuple2",
"Prims.unit",
"FStar.MSTTotal.put",
"Prims.eq2"
] | [] | (*
Copyright 2020 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.NMSTTotal
module W = FStar.Witnessed.Core
module P = FStar.Preorder
module M = FStar.MSTTotal
open FStar.Monotonic.Pure
type tape = nat -> bool
type repr
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
=
(tape & nat) ->
M.MSTATETOT (a & nat) state rel req (fun s0 (x, _) s1 -> ens s0 x s1)
let return (a:Type) (x:a) (state:Type u#2) (rel:P.preorder state)
: repr a state rel (fun _ -> True) (fun s0 r s1 -> r == x /\ s0 == s1)
=
fun (_, n) -> x, n
let bind
(a:Type)
(b:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:a -> M.pre_t state)
(ens_g:a -> M.post_t state b)
(f:repr a state rel req_f ens_f)
(g:(x:a -> repr b state rel (req_g x) (ens_g x)))
: repr b state rel
(fun s0 -> req_f s0 /\ (forall x s1. ens_f s0 x s1 ==> (req_g x) s1))
(fun s0 r s2 -> req_f s0 /\ (exists x s1. ens_f s0 x s1 /\ (req_g x) s1 /\ (ens_g x) s1 r s2))
=
fun (t, n) ->
let x, n1 = f (t, n) in
(g x) (t, n1)
let subcomp
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_f:M.pre_t state)
(ens_f:M.post_t state a)
(req_g:M.pre_t state)
(ens_g:M.post_t state a)
(f:repr a state rel req_f ens_f)
: Pure (repr a state rel req_g ens_g)
(requires
(forall s. req_g s ==> req_f s) /\
(forall s0 x s1. (req_g s0 /\ ens_f s0 x s1) ==> ens_g s0 x s1))
(ensures fun _ -> True)
=
f
let if_then_else
(a:Type)
(state:Type u#2)
(rel:P.preorder state)
(req_then:M.pre_t state)
(ens_then:M.post_t state a)
(req_else:M.pre_t state)
(ens_else:M.post_t state a)
(f:repr a state rel req_then ens_then)
(g:repr a state rel req_else ens_else)
(p:bool)
: Type
=
repr a state rel
(fun s0 -> (p ==> req_then s0) /\ ((~ p) ==> req_else s0))
(fun s0 x s1 -> (p ==> ens_then s0 x s1) /\ ((~ p) ==> ens_else s0 x s1))
[@@ primitive_extraction]
total
reflectable
effect {
NMSTATETOT (a:Type)
([@@@ effect_param] state:Type u#2)
([@@@ effect_param] rel:P.preorder state)
(req:M.pre_t state)
(ens:M.post_t state a)
with { repr; return; bind; subcomp; if_then_else }
}
[@@ noextract_to "krml"]
let get (#state:Type u#2) (#rel:P.preorder state) ()
: NMSTATETOT state state rel
(fun _ -> True)
(fun s0 s s1 -> s0 == s /\ s == s1)
=
NMSTATETOT?.reflect (fun (_, n) -> MSTTotal.get (), n)
[@@ noextract_to "krml"]
let put (#state:Type u#2) (#rel:P.preorder state) (s:state)
: NMSTATETOT unit state rel
(fun s0 -> rel s0 s)
(fun _ _ s1 -> s1 == s) | false | false | FStar.NMSTTotal.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 put (#state: Type u#2) (#rel: P.preorder state) (s: state)
: NMSTATETOT unit state rel (fun s0 -> rel s0 s) (fun _ _ s1 -> s1 == s) | [] | FStar.NMSTTotal.put | {
"file_name": "ulib/experimental/FStar.NMSTTotal.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | s: state -> FStar.NMSTTotal.NMSTATETOT Prims.unit | {
"end_col": 55,
"end_line": 123,
"start_col": 2,
"start_line": 123
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Rewrite",
"short_module": "Rewrite"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Return",
"short_module": "Return"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Admit",
"short_module": "Admit"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Par",
"short_module": "Par"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Exists",
"short_module": "Exists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.STApp",
"short_module": "STApp"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.While",
"short_module": "While"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocalArray",
"short_module": "WithLocalArray"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocal",
"short_module": "WithLocal"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Bind",
"short_module": "Bind"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.If",
"short_module": "If"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Abs",
"short_module": "Abs"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.VPropEquiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Bind",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let default_binder_annot = {
binder_ppname = ppname_default;
binder_ty = tm_unknown
} | let default_binder_annot = | false | null | false | { binder_ppname = ppname_default; binder_ty = tm_unknown } | {
"checked_file": "Pulse.Checker.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.FV.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Checker.WithLocalArray.fsti.checked",
"Pulse.Checker.WithLocal.fsti.checked",
"Pulse.Checker.While.fsti.checked",
"Pulse.Checker.VPropEquiv.fsti.checked",
"Pulse.Checker.STApp.fsti.checked",
"Pulse.Checker.Rewrite.fsti.checked",
"Pulse.Checker.Return.fsti.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Par.fsti.checked",
"Pulse.Checker.Match.fsti.checked",
"Pulse.Checker.IntroPure.fsti.checked",
"Pulse.Checker.If.fsti.checked",
"Pulse.Checker.Exists.fsti.checked",
"Pulse.Checker.Bind.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"Pulse.Checker.AssertWithBinders.fsti.checked",
"Pulse.Checker.Admit.fsti.checked",
"Pulse.Checker.Abs.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Builtins.fst.checked",
"FStar.String.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.fst"
} | [
"total"
] | [
"Pulse.Syntax.Base.Mkbinder",
"Pulse.Syntax.Base.tm_unknown",
"Pulse.Syntax.Base.ppname_default"
] | [] | module Pulse.Checker
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Reflection.Util
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Pure
open Pulse.Checker.Bind
open Pulse.Checker.VPropEquiv
open Pulse.Checker.Base
module P = Pulse.Syntax.Printer
module RTB = FStar.Tactics.Builtins
module FV = Pulse.Typing.FV
module RU = Pulse.RuntimeUtils
module Metatheory = Pulse.Typing.Metatheory
module Abs = Pulse.Checker.Abs
module If = Pulse.Checker.If
module Bind = Pulse.Checker.Bind
module Match = Pulse.Checker.Match
module WithLocal = Pulse.Checker.WithLocal
module WithLocalArray = Pulse.Checker.WithLocalArray
module While = Pulse.Checker.While
module STApp = Pulse.Checker.STApp
module Exists = Pulse.Checker.Exists
module Par = Pulse.Checker.Par
module Admit = Pulse.Checker.Admit
module Return = Pulse.Checker.Return
module Rewrite = Pulse.Checker.Rewrite
module ElimPure = Pulse.Checker.Prover.ElimPure
module ElimExists = Pulse.Checker.Prover.ElimExists
let terms_to_string (t:list term)
: T.Tac string
= String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t) | false | true | Pulse.Checker.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 default_binder_annot : Pulse.Syntax.Base.binder | [] | Pulse.Checker.default_binder_annot | {
"file_name": "lib/steel/pulse/Pulse.Checker.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Pulse.Syntax.Base.binder | {
"end_col": 26,
"end_line": 44,
"start_col": 4,
"start_line": 43
} |
|
FStar.Tactics.Effect.Tac | val terms_to_string (t: list term) : T.Tac string | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Rewrite",
"short_module": "Rewrite"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Return",
"short_module": "Return"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Admit",
"short_module": "Admit"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Par",
"short_module": "Par"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Exists",
"short_module": "Exists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.STApp",
"short_module": "STApp"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.While",
"short_module": "While"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocalArray",
"short_module": "WithLocalArray"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocal",
"short_module": "WithLocal"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Bind",
"short_module": "Bind"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.If",
"short_module": "If"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Abs",
"short_module": "Abs"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.VPropEquiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Bind",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let terms_to_string (t:list term)
: T.Tac string
= String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t) | val terms_to_string (t: list term) : T.Tac string
let terms_to_string (t: list term) : T.Tac string = | true | null | false | String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t) | {
"checked_file": "Pulse.Checker.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.FV.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Checker.WithLocalArray.fsti.checked",
"Pulse.Checker.WithLocal.fsti.checked",
"Pulse.Checker.While.fsti.checked",
"Pulse.Checker.VPropEquiv.fsti.checked",
"Pulse.Checker.STApp.fsti.checked",
"Pulse.Checker.Rewrite.fsti.checked",
"Pulse.Checker.Return.fsti.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Par.fsti.checked",
"Pulse.Checker.Match.fsti.checked",
"Pulse.Checker.IntroPure.fsti.checked",
"Pulse.Checker.If.fsti.checked",
"Pulse.Checker.Exists.fsti.checked",
"Pulse.Checker.Bind.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"Pulse.Checker.AssertWithBinders.fsti.checked",
"Pulse.Checker.Admit.fsti.checked",
"Pulse.Checker.Abs.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Builtins.fst.checked",
"FStar.String.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.fst"
} | [] | [
"Prims.list",
"Pulse.Syntax.Base.term",
"FStar.String.concat",
"Prims.string",
"FStar.Tactics.Util.map",
"Pulse.Syntax.Printer.term_to_string"
] | [] | module Pulse.Checker
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Reflection.Util
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Pure
open Pulse.Checker.Bind
open Pulse.Checker.VPropEquiv
open Pulse.Checker.Base
module P = Pulse.Syntax.Printer
module RTB = FStar.Tactics.Builtins
module FV = Pulse.Typing.FV
module RU = Pulse.RuntimeUtils
module Metatheory = Pulse.Typing.Metatheory
module Abs = Pulse.Checker.Abs
module If = Pulse.Checker.If
module Bind = Pulse.Checker.Bind
module Match = Pulse.Checker.Match
module WithLocal = Pulse.Checker.WithLocal
module WithLocalArray = Pulse.Checker.WithLocalArray
module While = Pulse.Checker.While
module STApp = Pulse.Checker.STApp
module Exists = Pulse.Checker.Exists
module Par = Pulse.Checker.Par
module Admit = Pulse.Checker.Admit
module Return = Pulse.Checker.Return
module Rewrite = Pulse.Checker.Rewrite
module ElimPure = Pulse.Checker.Prover.ElimPure
module ElimExists = Pulse.Checker.Prover.ElimExists
let terms_to_string (t:list term) | false | false | Pulse.Checker.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 terms_to_string (t: list term) : T.Tac string | [] | Pulse.Checker.terms_to_string | {
"file_name": "lib/steel/pulse/Pulse.Checker.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: Prims.list Pulse.Syntax.Base.term -> FStar.Tactics.Effect.Tac Prims.string | {
"end_col": 68,
"end_line": 40,
"start_col": 4,
"start_line": 40
} |
FStar.Tactics.Effect.Tac | val transform_to_unary_intro_exists (g: env) (t: term) (ws: list term) : T.Tac st_term | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Rewrite",
"short_module": "Rewrite"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Return",
"short_module": "Return"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Admit",
"short_module": "Admit"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Par",
"short_module": "Par"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Exists",
"short_module": "Exists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.STApp",
"short_module": "STApp"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.While",
"short_module": "While"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocalArray",
"short_module": "WithLocalArray"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocal",
"short_module": "WithLocal"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Bind",
"short_module": "Bind"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.If",
"short_module": "If"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Abs",
"short_module": "Abs"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.VPropEquiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Bind",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_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 transform_to_unary_intro_exists (g:env) (t:term) (ws:list term)
: T.Tac st_term =
match ws with
| [] -> fail g (Some t.range) "intro exists with empty witnesses"
| [w] ->
if Tm_ExistsSL? t.t
then wtag (Some STT_Ghost) (Tm_IntroExists {p=t;witnesses=[w]})
else fail g (Some t.range) "intro exists with non-existential"
| w::ws ->
match t.t with
| Tm_ExistsSL u b body ->
let body = subst_term body [ DT 0 w ] in
let st = transform_to_unary_intro_exists g body ws in
// w is the witness
let intro = wtag None (Tm_IntroExists {p=t;witnesses=[w]}) in
wtag None
(Tm_Bind {binder=null_binder tm_unit;
head=st;
body= intro})
| _ -> fail g (Some t.range) "intro exists with non-existential" | val transform_to_unary_intro_exists (g: env) (t: term) (ws: list term) : T.Tac st_term
let rec transform_to_unary_intro_exists (g: env) (t: term) (ws: list term) : T.Tac st_term = | true | null | false | match ws with
| [] -> fail g (Some t.range) "intro exists with empty witnesses"
| [w] ->
if Tm_ExistsSL? t.t
then wtag (Some STT_Ghost) (Tm_IntroExists ({ p = t; witnesses = [w] }))
else fail g (Some t.range) "intro exists with non-existential"
| w :: ws ->
match t.t with
| Tm_ExistsSL u b body ->
let body = subst_term body [DT 0 w] in
let st = transform_to_unary_intro_exists g body ws in
let intro = wtag None (Tm_IntroExists ({ p = t; witnesses = [w] })) in
wtag None (Tm_Bind ({ binder = null_binder tm_unit; head = st; body = intro }))
| _ -> fail g (Some t.range) "intro exists with non-existential" | {
"checked_file": "Pulse.Checker.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.FV.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Checker.WithLocalArray.fsti.checked",
"Pulse.Checker.WithLocal.fsti.checked",
"Pulse.Checker.While.fsti.checked",
"Pulse.Checker.VPropEquiv.fsti.checked",
"Pulse.Checker.STApp.fsti.checked",
"Pulse.Checker.Rewrite.fsti.checked",
"Pulse.Checker.Return.fsti.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Par.fsti.checked",
"Pulse.Checker.Match.fsti.checked",
"Pulse.Checker.IntroPure.fsti.checked",
"Pulse.Checker.If.fsti.checked",
"Pulse.Checker.Exists.fsti.checked",
"Pulse.Checker.Bind.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"Pulse.Checker.AssertWithBinders.fsti.checked",
"Pulse.Checker.Admit.fsti.checked",
"Pulse.Checker.Abs.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Builtins.fst.checked",
"FStar.String.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.fst"
} | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Prims.list",
"Pulse.Typing.Env.fail",
"Pulse.Syntax.Base.st_term",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.range",
"Pulse.Syntax.Base.__proj__Mkterm__item__range",
"Pulse.Syntax.Base.uu___is_Tm_ExistsSL",
"Pulse.Syntax.Base.__proj__Mkterm__item__t",
"Pulse.Typing.wtag",
"Pulse.Syntax.Base.ctag",
"Pulse.Syntax.Base.STT_Ghost",
"Pulse.Syntax.Base.Tm_IntroExists",
"Pulse.Syntax.Base.Mkst_term'__Tm_IntroExists__payload",
"Prims.Cons",
"Prims.Nil",
"Prims.bool",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.binder",
"FStar.Pervasives.Native.None",
"Pulse.Syntax.Base.Tm_Bind",
"Pulse.Syntax.Base.Mkst_term'__Tm_Bind__payload",
"Pulse.Syntax.Base.null_binder",
"Pulse.Typing.tm_unit",
"Pulse.Checker.transform_to_unary_intro_exists",
"Pulse.Syntax.Naming.subst_term",
"Pulse.Syntax.Naming.subst_elt",
"Pulse.Syntax.Naming.DT",
"Pulse.Syntax.Base.term'"
] | [] | module Pulse.Checker
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Reflection.Util
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Pure
open Pulse.Checker.Bind
open Pulse.Checker.VPropEquiv
open Pulse.Checker.Base
module P = Pulse.Syntax.Printer
module RTB = FStar.Tactics.Builtins
module FV = Pulse.Typing.FV
module RU = Pulse.RuntimeUtils
module Metatheory = Pulse.Typing.Metatheory
module Abs = Pulse.Checker.Abs
module If = Pulse.Checker.If
module Bind = Pulse.Checker.Bind
module Match = Pulse.Checker.Match
module WithLocal = Pulse.Checker.WithLocal
module WithLocalArray = Pulse.Checker.WithLocalArray
module While = Pulse.Checker.While
module STApp = Pulse.Checker.STApp
module Exists = Pulse.Checker.Exists
module Par = Pulse.Checker.Par
module Admit = Pulse.Checker.Admit
module Return = Pulse.Checker.Return
module Rewrite = Pulse.Checker.Rewrite
module ElimPure = Pulse.Checker.Prover.ElimPure
module ElimExists = Pulse.Checker.Prover.ElimExists
let terms_to_string (t:list term)
: T.Tac string
= String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t)
let default_binder_annot = {
binder_ppname = ppname_default;
binder_ty = tm_unknown
}
let rec gen_names_for_unknowns (g:env) (t:term) (ws:list term)
: T.Tac (list (nvar & term) & // new names with their types
term & // opened vprop
list term) // new list of witnesses with _ replaced with corresponding new names
= match ws with
| [] -> [], t, []
| w::ws ->
match t.t with
| Tm_ExistsSL _ b body ->
let xopt, w, g =
match w.t with
| Tm_Unknown ->
let x = fresh g in
Some x,
tm_var {nm_index=x;nm_ppname=b.binder_ppname},
push_binding g x b.binder_ppname b.binder_ty
| _ -> None, w, g in
let t : term = open_term' body w 0 in
let new_names, t, ws = gen_names_for_unknowns g t ws in
(match xopt with
| Some x ->
((b.binder_ppname, x), b.binder_ty)::new_names,
t,
w::ws
| None -> new_names, t, w::ws)
| _ -> fail g (Some t.range) "intro exists with non-existential"
let instantiate_unknown_witnesses (g:env) (t:st_term { Tm_IntroExists? t.term })
: T.Tac (option st_term) =
let Tm_IntroExists { p; witnesses=ws } = t.term in
let new_names, opened_p, new_ws = gen_names_for_unknowns g p ws in
match new_names with
| [] -> None
| _ ->
let e2 = {t with term=Tm_IntroExists { p; witnesses=new_ws }} in
let e1 =
let hint_type = ASSERT { p = opened_p } in
let binders = [] in
{term=Tm_ProofHintWithBinders { hint_type;binders;t=e2 }; range=t.range; effect_tag=as_effect_hint STT_Ghost } in
let t =
L.fold_right
(fun new_name (e:st_term { Tm_ProofHintWithBinders? e.term }) ->
let (ppname, x), ty = new_name in
let e = close_st_term' e x 0 in
match e.term with
| Tm_ProofHintWithBinders {hint_type;binders;t} ->
let new_binder = {binder_ty=ty; binder_ppname=ppname} in
let t' = Tm_ProofHintWithBinders {hint_type;binders=new_binder::binders;t} in
{e with term=t'})
new_names
e1 in
Some t
let rec transform_to_unary_intro_exists (g:env) (t:term) (ws:list term)
: T.Tac st_term = | false | false | Pulse.Checker.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 transform_to_unary_intro_exists (g: env) (t: term) (ws: list term) : T.Tac st_term | [
"recursion"
] | Pulse.Checker.transform_to_unary_intro_exists | {
"file_name": "lib/steel/pulse/Pulse.Checker.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | g: Pulse.Typing.Env.env -> t: Pulse.Syntax.Base.term -> ws: Prims.list Pulse.Syntax.Base.term
-> FStar.Tactics.Effect.Tac Pulse.Syntax.Base.st_term | {
"end_col": 68,
"end_line": 124,
"start_col": 2,
"start_line": 106
} |
FStar.Tactics.Effect.Tac | val instantiate_unknown_witnesses (g: env) (t: st_term{Tm_IntroExists? t.term})
: T.Tac (option st_term) | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Rewrite",
"short_module": "Rewrite"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Return",
"short_module": "Return"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Admit",
"short_module": "Admit"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Par",
"short_module": "Par"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Exists",
"short_module": "Exists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.STApp",
"short_module": "STApp"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.While",
"short_module": "While"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocalArray",
"short_module": "WithLocalArray"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocal",
"short_module": "WithLocal"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Bind",
"short_module": "Bind"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.If",
"short_module": "If"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Abs",
"short_module": "Abs"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.VPropEquiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Bind",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let instantiate_unknown_witnesses (g:env) (t:st_term { Tm_IntroExists? t.term })
: T.Tac (option st_term) =
let Tm_IntroExists { p; witnesses=ws } = t.term in
let new_names, opened_p, new_ws = gen_names_for_unknowns g p ws in
match new_names with
| [] -> None
| _ ->
let e2 = {t with term=Tm_IntroExists { p; witnesses=new_ws }} in
let e1 =
let hint_type = ASSERT { p = opened_p } in
let binders = [] in
{term=Tm_ProofHintWithBinders { hint_type;binders;t=e2 }; range=t.range; effect_tag=as_effect_hint STT_Ghost } in
let t =
L.fold_right
(fun new_name (e:st_term { Tm_ProofHintWithBinders? e.term }) ->
let (ppname, x), ty = new_name in
let e = close_st_term' e x 0 in
match e.term with
| Tm_ProofHintWithBinders {hint_type;binders;t} ->
let new_binder = {binder_ty=ty; binder_ppname=ppname} in
let t' = Tm_ProofHintWithBinders {hint_type;binders=new_binder::binders;t} in
{e with term=t'})
new_names
e1 in
Some t | val instantiate_unknown_witnesses (g: env) (t: st_term{Tm_IntroExists? t.term})
: T.Tac (option st_term)
let instantiate_unknown_witnesses (g: env) (t: st_term{Tm_IntroExists? t.term})
: T.Tac (option st_term) = | true | null | false | let Tm_IntroExists { p = p ; witnesses = ws } = t.term in
let new_names, opened_p, new_ws = gen_names_for_unknowns g p ws in
match new_names with
| [] -> None
| _ ->
let e2 = { t with term = Tm_IntroExists ({ p = p; witnesses = new_ws }) } in
let e1 =
let hint_type = ASSERT ({ p = opened_p }) in
let binders = [] in
{
term = Tm_ProofHintWithBinders ({ hint_type = hint_type; binders = binders; t = e2 });
range = t.range;
effect_tag = as_effect_hint STT_Ghost
}
in
let t =
L.fold_right (fun new_name (e: st_term{Tm_ProofHintWithBinders? e.term}) ->
let (ppname, x), ty = new_name in
let e = close_st_term' e x 0 in
match e.term with
| Tm_ProofHintWithBinders { hint_type = hint_type ; binders = binders ; t = t } ->
let new_binder = { binder_ty = ty; binder_ppname = ppname } in
let t' =
Tm_ProofHintWithBinders
({ hint_type = hint_type; binders = new_binder :: binders; t = t })
in
{ e with term = t' })
new_names
e1
in
Some t | {
"checked_file": "Pulse.Checker.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.FV.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Checker.WithLocalArray.fsti.checked",
"Pulse.Checker.WithLocal.fsti.checked",
"Pulse.Checker.While.fsti.checked",
"Pulse.Checker.VPropEquiv.fsti.checked",
"Pulse.Checker.STApp.fsti.checked",
"Pulse.Checker.Rewrite.fsti.checked",
"Pulse.Checker.Return.fsti.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Par.fsti.checked",
"Pulse.Checker.Match.fsti.checked",
"Pulse.Checker.IntroPure.fsti.checked",
"Pulse.Checker.If.fsti.checked",
"Pulse.Checker.Exists.fsti.checked",
"Pulse.Checker.Bind.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"Pulse.Checker.AssertWithBinders.fsti.checked",
"Pulse.Checker.Admit.fsti.checked",
"Pulse.Checker.Abs.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Builtins.fst.checked",
"FStar.String.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.fst"
} | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.st_term",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_Tm_IntroExists",
"Pulse.Syntax.Base.__proj__Mkst_term__item__term",
"Pulse.Syntax.Base.vprop",
"Prims.list",
"Pulse.Syntax.Base.term",
"FStar.Pervasives.Native.tuple2",
"Pulse.Syntax.Base.nvar",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.uu___is_Tm_ProofHintWithBinders",
"FStar.List.Tot.Base.fold_right",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Base.proof_hint_type",
"Pulse.Syntax.Base.binder",
"Pulse.Syntax.Base.Mkst_term",
"Pulse.Syntax.Base.__proj__Mkst_term__item__range",
"Pulse.Syntax.Base.__proj__Mkst_term__item__effect_tag",
"Pulse.Syntax.Base.st_term'",
"Pulse.Syntax.Base.Tm_ProofHintWithBinders",
"Pulse.Syntax.Base.Mkst_term'__Tm_ProofHintWithBinders__payload",
"Prims.Cons",
"Pulse.Syntax.Base.Mkbinder",
"Pulse.Syntax.Naming.close_st_term'",
"Pulse.Syntax.Base.as_effect_hint",
"Pulse.Syntax.Base.STT_Ghost",
"Prims.Nil",
"Pulse.Syntax.Base.ASSERT",
"Pulse.Syntax.Base.Mkproof_hint_type__ASSERT__payload",
"Pulse.Syntax.Base.Tm_IntroExists",
"Pulse.Syntax.Base.Mkst_term'__Tm_IntroExists__payload",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple3",
"Pulse.Checker.gen_names_for_unknowns"
] | [] | module Pulse.Checker
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Reflection.Util
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Pure
open Pulse.Checker.Bind
open Pulse.Checker.VPropEquiv
open Pulse.Checker.Base
module P = Pulse.Syntax.Printer
module RTB = FStar.Tactics.Builtins
module FV = Pulse.Typing.FV
module RU = Pulse.RuntimeUtils
module Metatheory = Pulse.Typing.Metatheory
module Abs = Pulse.Checker.Abs
module If = Pulse.Checker.If
module Bind = Pulse.Checker.Bind
module Match = Pulse.Checker.Match
module WithLocal = Pulse.Checker.WithLocal
module WithLocalArray = Pulse.Checker.WithLocalArray
module While = Pulse.Checker.While
module STApp = Pulse.Checker.STApp
module Exists = Pulse.Checker.Exists
module Par = Pulse.Checker.Par
module Admit = Pulse.Checker.Admit
module Return = Pulse.Checker.Return
module Rewrite = Pulse.Checker.Rewrite
module ElimPure = Pulse.Checker.Prover.ElimPure
module ElimExists = Pulse.Checker.Prover.ElimExists
let terms_to_string (t:list term)
: T.Tac string
= String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t)
let default_binder_annot = {
binder_ppname = ppname_default;
binder_ty = tm_unknown
}
let rec gen_names_for_unknowns (g:env) (t:term) (ws:list term)
: T.Tac (list (nvar & term) & // new names with their types
term & // opened vprop
list term) // new list of witnesses with _ replaced with corresponding new names
= match ws with
| [] -> [], t, []
| w::ws ->
match t.t with
| Tm_ExistsSL _ b body ->
let xopt, w, g =
match w.t with
| Tm_Unknown ->
let x = fresh g in
Some x,
tm_var {nm_index=x;nm_ppname=b.binder_ppname},
push_binding g x b.binder_ppname b.binder_ty
| _ -> None, w, g in
let t : term = open_term' body w 0 in
let new_names, t, ws = gen_names_for_unknowns g t ws in
(match xopt with
| Some x ->
((b.binder_ppname, x), b.binder_ty)::new_names,
t,
w::ws
| None -> new_names, t, w::ws)
| _ -> fail g (Some t.range) "intro exists with non-existential" | false | false | Pulse.Checker.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 instantiate_unknown_witnesses (g: env) (t: st_term{Tm_IntroExists? t.term})
: T.Tac (option st_term) | [] | Pulse.Checker.instantiate_unknown_witnesses | {
"file_name": "lib/steel/pulse/Pulse.Checker.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | g: Pulse.Typing.Env.env -> t: Pulse.Syntax.Base.st_term{Tm_IntroExists? (Mkst_term?.term t)}
-> FStar.Tactics.Effect.Tac (FStar.Pervasives.Native.option Pulse.Syntax.Base.st_term) | {
"end_col": 10,
"end_line": 101,
"start_col": 28,
"start_line": 75
} |
FStar.Tactics.Effect.Tac | val gen_names_for_unknowns (g: env) (t: term) (ws: list term)
: T.Tac (list (nvar & term) & term & list term) | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Rewrite",
"short_module": "Rewrite"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Return",
"short_module": "Return"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Admit",
"short_module": "Admit"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Par",
"short_module": "Par"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Exists",
"short_module": "Exists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.STApp",
"short_module": "STApp"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.While",
"short_module": "While"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocalArray",
"short_module": "WithLocalArray"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocal",
"short_module": "WithLocal"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Bind",
"short_module": "Bind"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.If",
"short_module": "If"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Abs",
"short_module": "Abs"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.VPropEquiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Bind",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_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 gen_names_for_unknowns (g:env) (t:term) (ws:list term)
: T.Tac (list (nvar & term) & // new names with their types
term & // opened vprop
list term) // new list of witnesses with _ replaced with corresponding new names
= match ws with
| [] -> [], t, []
| w::ws ->
match t.t with
| Tm_ExistsSL _ b body ->
let xopt, w, g =
match w.t with
| Tm_Unknown ->
let x = fresh g in
Some x,
tm_var {nm_index=x;nm_ppname=b.binder_ppname},
push_binding g x b.binder_ppname b.binder_ty
| _ -> None, w, g in
let t : term = open_term' body w 0 in
let new_names, t, ws = gen_names_for_unknowns g t ws in
(match xopt with
| Some x ->
((b.binder_ppname, x), b.binder_ty)::new_names,
t,
w::ws
| None -> new_names, t, w::ws)
| _ -> fail g (Some t.range) "intro exists with non-existential" | val gen_names_for_unknowns (g: env) (t: term) (ws: list term)
: T.Tac (list (nvar & term) & term & list term)
let rec gen_names_for_unknowns (g: env) (t: term) (ws: list term)
: T.Tac (list (nvar & term) & term & list term) = | true | null | false | match ws with
| [] -> [], t, []
| w :: ws ->
match t.t with
| Tm_ExistsSL _ b body ->
let xopt, w, g =
match w.t with
| Tm_Unknown ->
let x = fresh g in
Some x,
tm_var ({ nm_index = x; nm_ppname = b.binder_ppname }),
push_binding g x b.binder_ppname b.binder_ty
| _ -> None, w, g
in
let t:term = open_term' body w 0 in
let new_names, t, ws = gen_names_for_unknowns g t ws in
(match xopt with
| Some x -> ((b.binder_ppname, x), b.binder_ty) :: new_names, t, w :: ws
| None -> new_names, t, w :: ws)
| _ -> fail g (Some t.range) "intro exists with non-existential" | {
"checked_file": "Pulse.Checker.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.FV.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Checker.WithLocalArray.fsti.checked",
"Pulse.Checker.WithLocal.fsti.checked",
"Pulse.Checker.While.fsti.checked",
"Pulse.Checker.VPropEquiv.fsti.checked",
"Pulse.Checker.STApp.fsti.checked",
"Pulse.Checker.Rewrite.fsti.checked",
"Pulse.Checker.Return.fsti.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Par.fsti.checked",
"Pulse.Checker.Match.fsti.checked",
"Pulse.Checker.IntroPure.fsti.checked",
"Pulse.Checker.If.fsti.checked",
"Pulse.Checker.Exists.fsti.checked",
"Pulse.Checker.Bind.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"Pulse.Checker.AssertWithBinders.fsti.checked",
"Pulse.Checker.Admit.fsti.checked",
"Pulse.Checker.Abs.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Builtins.fst.checked",
"FStar.String.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.fst"
} | [] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Prims.list",
"FStar.Pervasives.Native.Mktuple3",
"FStar.Pervasives.Native.tuple2",
"Pulse.Syntax.Base.nvar",
"Prims.Nil",
"FStar.Pervasives.Native.tuple3",
"Pulse.Syntax.Base.__proj__Mkterm__item__t",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.binder",
"FStar.Pervasives.Native.option",
"Pulse.Syntax.Base.var",
"Prims.Cons",
"FStar.Pervasives.Native.Mktuple2",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname",
"Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty",
"Pulse.Checker.gen_names_for_unknowns",
"Pulse.Syntax.Naming.open_term'",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Pure.tm_var",
"Pulse.Syntax.Base.Mknm",
"Pulse.Typing.Env.push_binding",
"Prims.l_not",
"Prims.b2t",
"FStar.Set.mem",
"Pulse.Typing.Env.dom",
"Pulse.Typing.Env.fresh",
"Pulse.Syntax.Base.term'",
"FStar.Pervasives.Native.None",
"Pulse.Typing.Env.fail",
"Pulse.Syntax.Base.range",
"Pulse.Syntax.Base.__proj__Mkterm__item__range"
] | [] | module Pulse.Checker
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Reflection.Util
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Pure
open Pulse.Checker.Bind
open Pulse.Checker.VPropEquiv
open Pulse.Checker.Base
module P = Pulse.Syntax.Printer
module RTB = FStar.Tactics.Builtins
module FV = Pulse.Typing.FV
module RU = Pulse.RuntimeUtils
module Metatheory = Pulse.Typing.Metatheory
module Abs = Pulse.Checker.Abs
module If = Pulse.Checker.If
module Bind = Pulse.Checker.Bind
module Match = Pulse.Checker.Match
module WithLocal = Pulse.Checker.WithLocal
module WithLocalArray = Pulse.Checker.WithLocalArray
module While = Pulse.Checker.While
module STApp = Pulse.Checker.STApp
module Exists = Pulse.Checker.Exists
module Par = Pulse.Checker.Par
module Admit = Pulse.Checker.Admit
module Return = Pulse.Checker.Return
module Rewrite = Pulse.Checker.Rewrite
module ElimPure = Pulse.Checker.Prover.ElimPure
module ElimExists = Pulse.Checker.Prover.ElimExists
let terms_to_string (t:list term)
: T.Tac string
= String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t)
let default_binder_annot = {
binder_ppname = ppname_default;
binder_ty = tm_unknown
}
let rec gen_names_for_unknowns (g:env) (t:term) (ws:list term)
: T.Tac (list (nvar & term) & // new names with their types
term & // opened vprop | false | false | Pulse.Checker.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 gen_names_for_unknowns (g: env) (t: term) (ws: list term)
: T.Tac (list (nvar & term) & term & list term) | [
"recursion"
] | Pulse.Checker.gen_names_for_unknowns | {
"file_name": "lib/steel/pulse/Pulse.Checker.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | g: Pulse.Typing.Env.env -> t: Pulse.Syntax.Base.term -> ws: Prims.list Pulse.Syntax.Base.term
-> FStar.Tactics.Effect.Tac
((Prims.list (Pulse.Syntax.Base.nvar * Pulse.Syntax.Base.term) * Pulse.Syntax.Base.term) *
Prims.list Pulse.Syntax.Base.term) | {
"end_col": 70,
"end_line": 72,
"start_col": 4,
"start_line": 51
} |
Prims.Tot | val check : check_t | [
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimExists",
"short_module": "ElimExists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Prover.ElimPure",
"short_module": "ElimPure"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Rewrite",
"short_module": "Rewrite"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Return",
"short_module": "Return"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Admit",
"short_module": "Admit"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Par",
"short_module": "Par"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Exists",
"short_module": "Exists"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.STApp",
"short_module": "STApp"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.While",
"short_module": "While"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocalArray",
"short_module": "WithLocalArray"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.WithLocal",
"short_module": "WithLocal"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Match",
"short_module": "Match"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Bind",
"short_module": "Bind"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.If",
"short_module": "If"
},
{
"abbrev": true,
"full_module": "Pulse.Checker.Abs",
"short_module": "Abs"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.Metatheory",
"short_module": "Metatheory"
},
{
"abbrev": true,
"full_module": "Pulse.RuntimeUtils",
"short_module": "RU"
},
{
"abbrev": true,
"full_module": "Pulse.Typing.FV",
"short_module": "FV"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.Builtins",
"short_module": "RTB"
},
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.VPropEquiv",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Bind",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse",
"short_module": null
},
{
"abbrev": false,
"full_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 check
(g0:env)
(pre0:term)
(pre0_typing: tot_typing g0 pre0 tm_vprop)
(post_hint:post_hint_opt g0)
(res_ppname:ppname)
(t:st_term) : T.Tac (checker_result_t g0 pre0 post_hint) =
// T.print (Printf.sprintf "At %s: context: %s, term: %s\n"
// (T.range_to_string t.range)
// (Pulse.Syntax.Printer.term_to_string pre0)
// (Pulse.Syntax.Printer.st_term_to_string t));
let (| g, pre, pre_typing, k_elim_pure |) =
Pulse.Checker.Prover.ElimPure.elim_pure pre0_typing in
let r : checker_result_t g pre post_hint =
let g = push_context (P.tag_of_st_term t) t.range g in
match t.term with
| Tm_Return _ ->
Return.check g pre pre_typing post_hint res_ppname t
| Tm_Abs _ -> T.fail "Tm_Abs check should not have been called in the checker"
| Tm_STApp _ ->
STApp.check g pre pre_typing post_hint res_ppname t
| Tm_ElimExists _ ->
Exists.check_elim_exists g pre pre_typing post_hint res_ppname t
| Tm_IntroExists { p; witnesses } ->
(match instantiate_unknown_witnesses g t with
| Some t ->
check g pre pre_typing post_hint res_ppname t
| None ->
match witnesses with
| [] -> fail g (Some t.range) "intro exists with empty witnesses"
| [_] ->
Exists.check_intro_exists g pre pre_typing post_hint res_ppname t None
| _ ->
let t = transform_to_unary_intro_exists g p witnesses in
check g pre pre_typing post_hint res_ppname t)
| Tm_Bind _ ->
Bind.check_bind g pre pre_typing post_hint res_ppname t check
| Tm_TotBind _ ->
Bind.check_tot_bind g pre pre_typing post_hint res_ppname t check
| Tm_If { b; then_=e1; else_=e2; post=post_if } ->
let post =
match post_if, post_hint with
| None, Some p -> p
| Some p, None ->
Checker.Base.intro_post_hint g None None p
| Some p, Some q ->
Pulse.Typing.Env.fail g (Some t.range)
(Printf.sprintf
"Multiple annotated postconditions---remove one of them.\n\
The context expects the postcondition %s,\n\
but this conditional was annotated with postcondition %s"
(P.term_to_string (q <: post_hint_t).post)
(P.term_to_string p))
| _, _ ->
Pulse.Typing.Env.fail g (Some t.range)
(Printf.sprintf
"Pulse cannot yet infer a postcondition for a non-tail conditional statement;\n\
Either annotate this `if` with `returns` clause; or rewrite your code to use a tail conditional")
in
let (| x, t, pre', g1, k |) : checker_result_t g pre (Some post) =
If.check g pre pre_typing post res_ppname b e1 e2 check in
(| x, t, pre', g1, k |)
| Tm_While _ ->
While.check g pre pre_typing post_hint res_ppname t check
| Tm_Match {sc;returns_=post_match;brs} ->
// TODO : dedup
let post =
match post_match, post_hint with
| None, Some p -> p
| Some p, None ->
Checker.Base.intro_post_hint g None None p
| Some p, Some q ->
Pulse.Typing.Env.fail g (Some t.range)
(Printf.sprintf
"Multiple annotated postconditions---remove one of them.\n\
The context expects the postcondition %s,\n\
but this conditional was annotated with postcondition %s"
(P.term_to_string (q <: post_hint_t).post)
(P.term_to_string p))
| _, _ ->
Pulse.Typing.Env.fail g (Some t.range)
(Printf.sprintf
"Pulse cannot yet infer a postcondition for a non-tail conditional statement;\n\
Either annotate this `if` with `returns` clause; or rewrite your code to use a tail conditional")
in
let (| x, ty, pre', g1, k |) =
Match.check g pre pre_typing post res_ppname sc brs check in
(| x, ty, pre', g1, k |)
| Tm_ProofHintWithBinders _ ->
Pulse.Checker.AssertWithBinders.check g pre pre_typing post_hint res_ppname t check
| Tm_WithLocal _ ->
WithLocal.check g pre pre_typing post_hint res_ppname t check
| Tm_WithLocalArray _ ->
WithLocalArray.check g pre pre_typing post_hint res_ppname t check
| Tm_Par _ ->
Par.check g pre pre_typing post_hint res_ppname t check
| Tm_IntroPure _ ->
Pulse.Checker.IntroPure.check g pre pre_typing post_hint res_ppname t
| Tm_Admit _ ->
Admit.check g pre pre_typing post_hint res_ppname t
| Tm_Rewrite _ ->
Rewrite.check g pre pre_typing post_hint res_ppname t
| _ -> T.fail "Checker form not implemented"
in
let (| x, g1, t, pre', k |) = r in
(| x, g1, t, pre', k_elab_trans k_elim_pure k |) | val check : check_t
let rec check
(g0: env)
(pre0: term)
(pre0_typing: tot_typing g0 pre0 tm_vprop)
(post_hint: post_hint_opt g0)
(res_ppname: ppname)
(t: st_term)
: T.Tac (checker_result_t g0 pre0 post_hint) = | false | null | false | let (| g , pre , pre_typing , k_elim_pure |) =
Pulse.Checker.Prover.ElimPure.elim_pure pre0_typing
in
let r:checker_result_t g pre post_hint =
let g = push_context (P.tag_of_st_term t) t.range g in
match t.term with
| Tm_Return _ -> Return.check g pre pre_typing post_hint res_ppname t
| Tm_Abs _ -> T.fail "Tm_Abs check should not have been called in the checker"
| Tm_STApp _ -> STApp.check g pre pre_typing post_hint res_ppname t
| Tm_ElimExists _ -> Exists.check_elim_exists g pre pre_typing post_hint res_ppname t
| Tm_IntroExists { p = p ; witnesses = witnesses } ->
(match instantiate_unknown_witnesses g t with
| Some t -> check g pre pre_typing post_hint res_ppname t
| None ->
match witnesses with
| [] -> fail g (Some t.range) "intro exists with empty witnesses"
| [_] -> Exists.check_intro_exists g pre pre_typing post_hint res_ppname t None
| _ ->
let t = transform_to_unary_intro_exists g p witnesses in
check g pre pre_typing post_hint res_ppname t)
| Tm_Bind _ -> Bind.check_bind g pre pre_typing post_hint res_ppname t check
| Tm_TotBind _ -> Bind.check_tot_bind g pre pre_typing post_hint res_ppname t check
| Tm_If { b = b ; then_ = e1 ; else_ = e2 ; post = post_if } ->
let post =
match post_if, post_hint with
| None, Some p -> p
| Some p, None -> Checker.Base.intro_post_hint g None None p
| Some p, Some q ->
Pulse.Typing.Env.fail g
(Some t.range)
(Printf.sprintf "Multiple annotated postconditions---remove one of them.\nThe context expects the postcondition %s,\nbut this conditional was annotated with postcondition %s"
(P.term_to_string (q <: post_hint_t).post)
(P.term_to_string p))
| _, _ ->
Pulse.Typing.Env.fail g
(Some t.range)
(Printf.sprintf "Pulse cannot yet infer a postcondition for a non-tail conditional statement;\nEither annotate this `if` with `returns` clause; or rewrite your code to use a tail conditional"
)
in
let (| x , t , pre' , g1 , k |):checker_result_t g pre (Some post) =
If.check g pre pre_typing post res_ppname b e1 e2 check
in
(| x, t, pre', g1, k |)
| Tm_While _ -> While.check g pre pre_typing post_hint res_ppname t check
| Tm_Match { sc = sc ; returns_ = post_match ; brs = brs } ->
let post =
match post_match, post_hint with
| None, Some p -> p
| Some p, None -> Checker.Base.intro_post_hint g None None p
| Some p, Some q ->
Pulse.Typing.Env.fail g
(Some t.range)
(Printf.sprintf "Multiple annotated postconditions---remove one of them.\nThe context expects the postcondition %s,\nbut this conditional was annotated with postcondition %s"
(P.term_to_string (q <: post_hint_t).post)
(P.term_to_string p))
| _, _ ->
Pulse.Typing.Env.fail g
(Some t.range)
(Printf.sprintf "Pulse cannot yet infer a postcondition for a non-tail conditional statement;\nEither annotate this `if` with `returns` clause; or rewrite your code to use a tail conditional"
)
in
let (| x , ty , pre' , g1 , k |) = Match.check g pre pre_typing post res_ppname sc brs check in
(| x, ty, pre', g1, k |)
| Tm_ProofHintWithBinders _ ->
Pulse.Checker.AssertWithBinders.check g pre pre_typing post_hint res_ppname t check
| Tm_WithLocal _ -> WithLocal.check g pre pre_typing post_hint res_ppname t check
| Tm_WithLocalArray _ -> WithLocalArray.check g pre pre_typing post_hint res_ppname t check
| Tm_Par _ -> Par.check g pre pre_typing post_hint res_ppname t check
| Tm_IntroPure _ -> Pulse.Checker.IntroPure.check g pre pre_typing post_hint res_ppname t
| Tm_Admit _ -> Admit.check g pre pre_typing post_hint res_ppname t
| Tm_Rewrite _ -> Rewrite.check g pre pre_typing post_hint res_ppname t
| _ -> T.fail "Checker form not implemented"
in
let (| x , g1 , t , pre' , k |) = r in
(| x, g1, t, pre', k_elab_trans k_elim_pure k |) | {
"checked_file": "Pulse.Checker.fst.checked",
"dependencies": [
"Pulse.Typing.Metatheory.fsti.checked",
"Pulse.Typing.FV.fsti.checked",
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.Combinators.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.RuntimeUtils.fsti.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Checker.WithLocalArray.fsti.checked",
"Pulse.Checker.WithLocal.fsti.checked",
"Pulse.Checker.While.fsti.checked",
"Pulse.Checker.VPropEquiv.fsti.checked",
"Pulse.Checker.STApp.fsti.checked",
"Pulse.Checker.Rewrite.fsti.checked",
"Pulse.Checker.Return.fsti.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.ElimPure.fsti.checked",
"Pulse.Checker.Prover.ElimExists.fsti.checked",
"Pulse.Checker.Par.fsti.checked",
"Pulse.Checker.Match.fsti.checked",
"Pulse.Checker.IntroPure.fsti.checked",
"Pulse.Checker.If.fsti.checked",
"Pulse.Checker.Exists.fsti.checked",
"Pulse.Checker.Bind.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"Pulse.Checker.AssertWithBinders.fsti.checked",
"Pulse.Checker.Admit.fsti.checked",
"Pulse.Checker.Abs.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Builtins.fst.checked",
"FStar.String.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Reflection.Typing.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.fst"
} | [
"total"
] | [
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Typing.tot_typing",
"Pulse.Syntax.Base.tm_vprop",
"Pulse.Typing.post_hint_opt",
"Pulse.Syntax.Base.ppname",
"Pulse.Syntax.Base.st_term",
"Pulse.Typing.Env.env_extends",
"Pulse.Checker.Base.continuation_elaborator",
"Pulse.Syntax.Base.var",
"FStar.Pervasives.dtuple3",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.typ",
"Pulse.Typing.universe_of",
"Prims.dtuple2",
"Pulse.Syntax.Base.vprop",
"FStar.Pervasives.dfst",
"Pulse.Checker.Base.checker_result_inv",
"FStar.Pervasives.Mkdtuple5",
"Pulse.Checker.Base.k_elab_trans",
"Pulse.Checker.Base.checker_result_t",
"Pulse.Syntax.Base.__proj__Mkst_term__item__term",
"Pulse.Syntax.Base.st_term'__Tm_Return__payload",
"Pulse.Checker.Return.check",
"Pulse.Syntax.Base.st_term'__Tm_Abs__payload",
"FStar.Tactics.V2.Derived.fail",
"Pulse.Syntax.Base.st_term'__Tm_STApp__payload",
"Pulse.Checker.STApp.check",
"Pulse.Syntax.Base.st_term'__Tm_ElimExists__payload",
"Pulse.Checker.Exists.check_elim_exists",
"Prims.list",
"Pulse.Checker.check",
"Pulse.Typing.Env.fail",
"FStar.Pervasives.Native.Some",
"Pulse.Syntax.Base.range",
"Pulse.Syntax.Base.__proj__Mkst_term__item__range",
"Pulse.Checker.Exists.check_intro_exists",
"FStar.Pervasives.Native.None",
"Pulse.Checker.Exists.intro_exists_vprop",
"Pulse.Checker.transform_to_unary_intro_exists",
"FStar.Pervasives.Native.option",
"Pulse.Checker.instantiate_unknown_witnesses",
"Pulse.Syntax.Base.st_term'__Tm_Bind__payload",
"Pulse.Checker.Bind.check_bind",
"Pulse.Syntax.Base.st_term'__Tm_TotBind__payload",
"Pulse.Checker.Bind.check_tot_bind",
"Pulse.Typing.post_hint_t",
"Pulse.Checker.If.check",
"FStar.Pervasives.Native.Mktuple2",
"Pulse.Checker.Base.intro_post_hint",
"Pulse.Syntax.Base.ctag",
"Pulse.Typing.post_hint_for_env",
"Prims.string",
"FStar.Printf.sprintf",
"Pulse.Syntax.Printer.term_to_string",
"Pulse.Typing.__proj__Mkpost_hint_t__item__post",
"Pulse.Syntax.Base.st_term'__Tm_While__payload",
"Pulse.Checker.While.check",
"FStar.Pervasives.Native.tuple2",
"Pulse.Syntax.Base.pattern",
"Pulse.Checker.Match.check",
"Pulse.Syntax.Base.st_term'__Tm_ProofHintWithBinders__payload",
"Pulse.Checker.AssertWithBinders.check",
"Pulse.Syntax.Base.st_term'__Tm_WithLocal__payload",
"Pulse.Checker.WithLocal.check",
"Pulse.Syntax.Base.st_term'__Tm_WithLocalArray__payload",
"Pulse.Checker.WithLocalArray.check",
"Pulse.Syntax.Base.st_term'__Tm_Par__payload",
"Pulse.Checker.Par.check",
"Pulse.Syntax.Base.st_term'__Tm_IntroPure__payload",
"Pulse.Checker.IntroPure.check",
"Pulse.Syntax.Base.st_term'__Tm_Admit__payload",
"Pulse.Checker.Admit.check",
"Pulse.Syntax.Base.st_term'__Tm_Rewrite__payload",
"Pulse.Checker.Rewrite.check",
"Pulse.Syntax.Base.st_term'",
"Prims.eq2",
"Pulse.Checker.Pure.push_context",
"Pulse.Syntax.Printer.tag_of_st_term",
"FStar.Pervasives.dtuple4",
"Pulse.Checker.Prover.ElimPure.elim_pure"
] | [] | module Pulse.Checker
module RT = FStar.Reflection.Typing
module R = FStar.Reflection.V2
module L = FStar.List.Tot
module T = FStar.Tactics.V2
open FStar.List.Tot
open Pulse.Syntax
open Pulse.Reflection.Util
open Pulse.Typing
open Pulse.Typing.Combinators
open Pulse.Checker.Pure
open Pulse.Checker.Bind
open Pulse.Checker.VPropEquiv
open Pulse.Checker.Base
module P = Pulse.Syntax.Printer
module RTB = FStar.Tactics.Builtins
module FV = Pulse.Typing.FV
module RU = Pulse.RuntimeUtils
module Metatheory = Pulse.Typing.Metatheory
module Abs = Pulse.Checker.Abs
module If = Pulse.Checker.If
module Bind = Pulse.Checker.Bind
module Match = Pulse.Checker.Match
module WithLocal = Pulse.Checker.WithLocal
module WithLocalArray = Pulse.Checker.WithLocalArray
module While = Pulse.Checker.While
module STApp = Pulse.Checker.STApp
module Exists = Pulse.Checker.Exists
module Par = Pulse.Checker.Par
module Admit = Pulse.Checker.Admit
module Return = Pulse.Checker.Return
module Rewrite = Pulse.Checker.Rewrite
module ElimPure = Pulse.Checker.Prover.ElimPure
module ElimExists = Pulse.Checker.Prover.ElimExists
let terms_to_string (t:list term)
: T.Tac string
= String.concat "\n" (T.map Pulse.Syntax.Printer.term_to_string t)
let default_binder_annot = {
binder_ppname = ppname_default;
binder_ty = tm_unknown
}
let rec gen_names_for_unknowns (g:env) (t:term) (ws:list term)
: T.Tac (list (nvar & term) & // new names with their types
term & // opened vprop
list term) // new list of witnesses with _ replaced with corresponding new names
= match ws with
| [] -> [], t, []
| w::ws ->
match t.t with
| Tm_ExistsSL _ b body ->
let xopt, w, g =
match w.t with
| Tm_Unknown ->
let x = fresh g in
Some x,
tm_var {nm_index=x;nm_ppname=b.binder_ppname},
push_binding g x b.binder_ppname b.binder_ty
| _ -> None, w, g in
let t : term = open_term' body w 0 in
let new_names, t, ws = gen_names_for_unknowns g t ws in
(match xopt with
| Some x ->
((b.binder_ppname, x), b.binder_ty)::new_names,
t,
w::ws
| None -> new_names, t, w::ws)
| _ -> fail g (Some t.range) "intro exists with non-existential"
let instantiate_unknown_witnesses (g:env) (t:st_term { Tm_IntroExists? t.term })
: T.Tac (option st_term) =
let Tm_IntroExists { p; witnesses=ws } = t.term in
let new_names, opened_p, new_ws = gen_names_for_unknowns g p ws in
match new_names with
| [] -> None
| _ ->
let e2 = {t with term=Tm_IntroExists { p; witnesses=new_ws }} in
let e1 =
let hint_type = ASSERT { p = opened_p } in
let binders = [] in
{term=Tm_ProofHintWithBinders { hint_type;binders;t=e2 }; range=t.range; effect_tag=as_effect_hint STT_Ghost } in
let t =
L.fold_right
(fun new_name (e:st_term { Tm_ProofHintWithBinders? e.term }) ->
let (ppname, x), ty = new_name in
let e = close_st_term' e x 0 in
match e.term with
| Tm_ProofHintWithBinders {hint_type;binders;t} ->
let new_binder = {binder_ty=ty; binder_ppname=ppname} in
let t' = Tm_ProofHintWithBinders {hint_type;binders=new_binder::binders;t} in
{e with term=t'})
new_names
e1 in
Some t
let rec transform_to_unary_intro_exists (g:env) (t:term) (ws:list term)
: T.Tac st_term =
match ws with
| [] -> fail g (Some t.range) "intro exists with empty witnesses"
| [w] ->
if Tm_ExistsSL? t.t
then wtag (Some STT_Ghost) (Tm_IntroExists {p=t;witnesses=[w]})
else fail g (Some t.range) "intro exists with non-existential"
| w::ws ->
match t.t with
| Tm_ExistsSL u b body ->
let body = subst_term body [ DT 0 w ] in
let st = transform_to_unary_intro_exists g body ws in
// w is the witness
let intro = wtag None (Tm_IntroExists {p=t;witnesses=[w]}) in
wtag None
(Tm_Bind {binder=null_binder tm_unit;
head=st;
body= intro})
| _ -> fail g (Some t.range) "intro exists with non-existential"
#push-options "--z3rlimit_factor 4 --fuel 0 --ifuel 1"
let rec check
(g0:env)
(pre0:term)
(pre0_typing: tot_typing g0 pre0 tm_vprop)
(post_hint:post_hint_opt g0) | false | true | Pulse.Checker.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 4,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val check : check_t | [
"recursion"
] | Pulse.Checker.check | {
"file_name": "lib/steel/pulse/Pulse.Checker.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Pulse.Checker.Base.check_t | {
"end_col": 50,
"end_line": 252,
"start_col": 60,
"start_line": 133
} |
FStar.Pervasives.Lemma | val store_post_modifies
(#a: Type)
(#rrel #rel: B.srel a)
(b: B.mbuffer a rrel rel)
(i: nat)
(j: nat{i + j <= B.length b})
(predicate: (Seq.seq a -> Type))
(h0 h1: HS.mem)
: Lemma (requires (B.live h0 b /\ LE.store_post b i j predicate h0 () h1))
(ensures (B.modifies (B.loc_buffer_from_to b (U32.uint_to_t i) (U32.uint_to_t (i + j))) h0 h1)
) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let store_post_modifies
(#a:Type) (#rrel #rel:B.srel a) (b:B.mbuffer a rrel rel)
(i:nat) (j:nat{i + j <= B.length b}) (predicate:Seq.seq a -> Type)
(h0: HS.mem)
(h1: HS.mem)
: Lemma
(requires (
B.live h0 b /\
LE.store_post b i j predicate h0 () h1
))
(ensures (
B.modifies (B.loc_buffer_from_to b (U32.uint_to_t i) (U32.uint_to_t (i + j))) h0 h1
))
= B.modifies_loc_buffer_from_to_intro b (U32.uint_to_t i) (U32.uint_to_t (i + j)) B.loc_none h0 h1 | val store_post_modifies
(#a: Type)
(#rrel #rel: B.srel a)
(b: B.mbuffer a rrel rel)
(i: nat)
(j: nat{i + j <= B.length b})
(predicate: (Seq.seq a -> Type))
(h0 h1: HS.mem)
: Lemma (requires (B.live h0 b /\ LE.store_post b i j predicate h0 () h1))
(ensures (B.modifies (B.loc_buffer_from_to b (U32.uint_to_t i) (U32.uint_to_t (i + j))) h0 h1)
)
let store_post_modifies
(#a: Type)
(#rrel #rel: B.srel a)
(b: B.mbuffer a rrel rel)
(i: nat)
(j: nat{i + j <= B.length b})
(predicate: (Seq.seq a -> Type))
(h0 h1: HS.mem)
: Lemma (requires (B.live h0 b /\ LE.store_post b i j predicate h0 () h1))
(ensures (B.modifies (B.loc_buffer_from_to b (U32.uint_to_t i) (U32.uint_to_t (i + j))) h0 h1)
) = | false | null | true | B.modifies_loc_buffer_from_to_intro b (U32.uint_to_t i) (U32.uint_to_t (i + j)) B.loc_none h0 h1 | {
"checked_file": "LowParse.Low.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Endianness.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.Endianness.fst"
} | [
"lemma"
] | [
"LowStar.Monotonic.Buffer.srel",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"LowStar.Monotonic.Buffer.length",
"FStar.Seq.Base.seq",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Monotonic.Buffer.modifies_loc_buffer_from_to_intro",
"FStar.UInt32.uint_to_t",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.unit",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Endianness.store_post",
"Prims.squash",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_buffer_from_to",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Low.Endianness
include LowParse.Low.Base
include LowStar.Endianness
module B = LowStar.Buffer
module HS = FStar.HyperStack
module Seq = FStar.Seq
module LE = LowStar.Endianness
module U32 = FStar.UInt32
let writable_store_pre
(#rrel: _)
(#rel: _)
(b: B.mbuffer byte rrel rel)
(i: nat)
(j: nat)
(predicate:Seq.seq byte -> Type)
(h: HS.mem)
: Lemma
(requires (
writable b i (i + j) h /\
i + j <= B.length b
))
(ensures (
LE.store_pre b i j predicate h
))
= let sb = B.as_seq h b in
let len = B.length b in
let phi
(s: Seq.seq byte)
: Lemma
(requires (
Seq.length s == len /\
Seq.equal (Seq.slice s 0 i) (Seq.slice sb 0 i) /\
Seq.equal (Seq.slice s (i + j) len) (Seq.slice sb (i + j) len) /\
predicate (Seq.slice s i (i + j))
))
(ensures (
rel sb s
))
= assert (sb `Seq.equal` Seq.replace_subseq sb i (i + j) (Seq.slice sb i (i + j)));
assert (s `Seq.equal` Seq.replace_subseq sb i (i + j) (Seq.slice s i (i + j)))
in
Classical.forall_intro (Classical.move_requires phi)
let store_post_modifies
(#a:Type) (#rrel #rel:B.srel a) (b:B.mbuffer a rrel rel)
(i:nat) (j:nat{i + j <= B.length b}) (predicate:Seq.seq a -> Type)
(h0: HS.mem)
(h1: HS.mem)
: Lemma
(requires (
B.live h0 b /\
LE.store_post b i j predicate h0 () h1
))
(ensures (
B.modifies (B.loc_buffer_from_to b (U32.uint_to_t i) (U32.uint_to_t (i + j))) h0 h1 | false | false | LowParse.Low.Endianness.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 store_post_modifies
(#a: Type)
(#rrel #rel: B.srel a)
(b: B.mbuffer a rrel rel)
(i: nat)
(j: nat{i + j <= B.length b})
(predicate: (Seq.seq a -> Type))
(h0 h1: HS.mem)
: Lemma (requires (B.live h0 b /\ LE.store_post b i j predicate h0 () h1))
(ensures (B.modifies (B.loc_buffer_from_to b (U32.uint_to_t i) (U32.uint_to_t (i + j))) h0 h1)
) | [] | LowParse.Low.Endianness.store_post_modifies | {
"file_name": "src/lowparse/LowParse.Low.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
b: LowStar.Monotonic.Buffer.mbuffer a rrel rel ->
i: Prims.nat ->
j: Prims.nat{i + j <= LowStar.Monotonic.Buffer.length b} ->
predicate: (_: FStar.Seq.Base.seq a -> Type0) ->
h0: FStar.Monotonic.HyperStack.mem ->
h1: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
LowStar.Monotonic.Buffer.live h0 b /\ LowStar.Endianness.store_post b i j predicate h0 () h1
)
(ensures
LowStar.Monotonic.Buffer.modifies (LowStar.Monotonic.Buffer.loc_buffer_from_to b
(FStar.UInt32.uint_to_t i)
(FStar.UInt32.uint_to_t (i + j)))
h0
h1) | {
"end_col": 98,
"end_line": 59,
"start_col": 2,
"start_line": 59
} |
FStar.Pervasives.Lemma | val writable_store_pre
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(i j: nat)
(predicate: (Seq.seq byte -> Type))
(h: HS.mem)
: Lemma (requires (writable b i (i + j) h /\ i + j <= B.length b))
(ensures (LE.store_pre b i j predicate h)) | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "LowStar.Endianness",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "LowStar.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Low",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let writable_store_pre
(#rrel: _)
(#rel: _)
(b: B.mbuffer byte rrel rel)
(i: nat)
(j: nat)
(predicate:Seq.seq byte -> Type)
(h: HS.mem)
: Lemma
(requires (
writable b i (i + j) h /\
i + j <= B.length b
))
(ensures (
LE.store_pre b i j predicate h
))
= let sb = B.as_seq h b in
let len = B.length b in
let phi
(s: Seq.seq byte)
: Lemma
(requires (
Seq.length s == len /\
Seq.equal (Seq.slice s 0 i) (Seq.slice sb 0 i) /\
Seq.equal (Seq.slice s (i + j) len) (Seq.slice sb (i + j) len) /\
predicate (Seq.slice s i (i + j))
))
(ensures (
rel sb s
))
= assert (sb `Seq.equal` Seq.replace_subseq sb i (i + j) (Seq.slice sb i (i + j)));
assert (s `Seq.equal` Seq.replace_subseq sb i (i + j) (Seq.slice s i (i + j)))
in
Classical.forall_intro (Classical.move_requires phi) | val writable_store_pre
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(i j: nat)
(predicate: (Seq.seq byte -> Type))
(h: HS.mem)
: Lemma (requires (writable b i (i + j) h /\ i + j <= B.length b))
(ensures (LE.store_pre b i j predicate h))
let writable_store_pre
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(i j: nat)
(predicate: (Seq.seq byte -> Type))
(h: HS.mem)
: Lemma (requires (writable b i (i + j) h /\ i + j <= B.length b))
(ensures (LE.store_pre b i j predicate h)) = | false | null | true | let sb = B.as_seq h b in
let len = B.length b in
let phi (s: Seq.seq byte)
: Lemma
(requires
(Seq.length s == len /\ Seq.equal (Seq.slice s 0 i) (Seq.slice sb 0 i) /\
Seq.equal (Seq.slice s (i + j) len) (Seq.slice sb (i + j) len) /\
predicate (Seq.slice s i (i + j)))) (ensures (rel sb s)) =
assert (sb `Seq.equal` (Seq.replace_subseq sb i (i + j) (Seq.slice sb i (i + j))));
assert (s `Seq.equal` (Seq.replace_subseq sb i (i + j) (Seq.slice s i (i + j))))
in
Classical.forall_intro (Classical.move_requires phi) | {
"checked_file": "LowParse.Low.Endianness.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Endianness.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.Endianness.fst"
} | [
"lemma"
] | [
"LowStar.Monotonic.Buffer.srel",
"LowParse.Bytes.byte",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"FStar.Seq.Base.seq",
"FStar.Monotonic.HyperStack.mem",
"FStar.Classical.forall_intro",
"Prims.l_imp",
"Prims.l_and",
"Prims.eq2",
"FStar.Seq.Base.length",
"FStar.Seq.Base.equal",
"FStar.Seq.Base.slice",
"Prims.op_Addition",
"FStar.Classical.move_requires",
"Prims.unit",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims._assert",
"FStar.Seq.Properties.replace_subseq",
"LowStar.Monotonic.Buffer.length",
"LowStar.Monotonic.Buffer.as_seq",
"LowParse.Low.Base.writable",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowStar.Endianness.store_pre"
] | [] | module LowParse.Low.Endianness
include LowParse.Low.Base
include LowStar.Endianness
module B = LowStar.Buffer
module HS = FStar.HyperStack
module Seq = FStar.Seq
module LE = LowStar.Endianness
module U32 = FStar.UInt32
let writable_store_pre
(#rrel: _)
(#rel: _)
(b: B.mbuffer byte rrel rel)
(i: nat)
(j: nat)
(predicate:Seq.seq byte -> Type)
(h: HS.mem)
: Lemma
(requires (
writable b i (i + j) h /\
i + j <= B.length b
))
(ensures (
LE.store_pre b i j predicate h | false | false | LowParse.Low.Endianness.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 writable_store_pre
(#rrel #rel: _)
(b: B.mbuffer byte rrel rel)
(i j: nat)
(predicate: (Seq.seq byte -> Type))
(h: HS.mem)
: Lemma (requires (writable b i (i + j) h /\ i + j <= B.length b))
(ensures (LE.store_pre b i j predicate h)) | [] | LowParse.Low.Endianness.writable_store_pre | {
"file_name": "src/lowparse/LowParse.Low.Endianness.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
b: LowStar.Monotonic.Buffer.mbuffer LowParse.Bytes.byte rrel rel ->
i: Prims.nat ->
j: Prims.nat ->
predicate: (_: FStar.Seq.Base.seq LowParse.Bytes.byte -> Type0) ->
h: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
LowParse.Low.Base.writable b i (i + j) h /\ i + j <= LowStar.Monotonic.Buffer.length b)
(ensures LowStar.Endianness.store_pre b i j predicate h) | {
"end_col": 54,
"end_line": 44,
"start_col": 1,
"start_line": 27
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint8 = Lib.IntTypes.uint8 | let uint8 = | false | null | false | Lib.IntTypes.uint8 | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint8"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul | false | true | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint8 : Type0 | [] | Hacl.Streaming.MD.uint8 | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 30,
"end_line": 25,
"start_col": 12,
"start_line": 25
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint32 = Lib.IntTypes.uint32 | let uint32 = | false | null | false | Lib.IntTypes.uint32 | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Lib.IntTypes.uint32"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8 | false | true | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint32 : Type0 | [] | Hacl.Streaming.MD.uint32 | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 32,
"end_line": 28,
"start_col": 13,
"start_line": 28
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let alg = md_alg | let alg = | false | null | false | md_alg | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Spec.Hash.Definitions.md_alg"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Hash.Definitions
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg | false | true | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val alg : Type0 | [] | Hacl.Streaming.MD.alg | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 16,
"end_line": 41,
"start_col": 10,
"start_line": 41
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hacl_sha2_256 = hacl_md SHA2_256 | let hacl_sha2_256 = | false | null | false | hacl_md SHA2_256 | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.hacl_md",
"Spec.Hash.Definitions.SHA2_256"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Hash.Definitions
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
inline_for_extraction noextract
let alg = md_alg
inline_for_extraction noextract
let init_elem (a : alg) : word a =
match a with
| MD5 | SHA1 | SHA2_256 | SHA2_224 -> Lib.IntTypes.u32 0
| SHA2_384 | SHA2_512 -> Lib.IntTypes.u64 0
inline_for_extraction noextract
let state_t (a : alg) = stateful_buffer (word a) (D.impl_state_len (|a, ()|)) (init_elem a) unit
inline_for_extraction noextract
let update_multi_s (a : alg) () acc (prevlen : nat) input =
Agile.(update_multi a acc () input)
noextract
let update_multi_zero (a : alg) () acc (prevlen : nat) :
Lemma(update_multi_s a () acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
#push-options "--ifuel 1"
// TODO: this is the third copy of this lemma!! why?!
noextract
let update_multi_associative (a : alg) () acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
update_multi_s a () (update_multi_s a () acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a () acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let md_prevlen (a: alg) (len: D.(len: U64.t { U64.v len % U32.v (block_len a) = 0 })): D.prev_len_t a =
if a = SHA2_384 || a = SHA2_512 then FStar.Int.Cast.Full.uint64_to_uint128 len else len
/// This proof usually succeeds fast but we increase the rlimit for safety
#push-options "--z3rlimit 500 --ifuel 1"
inline_for_extraction noextract
let hacl_md (a:alg)// : block unit =
=
Block
Erased
(state_t a) (* state *)
(stateful_unused unit) (* key *)
unit
(fun () -> max_input_len64 a) (* max_input_len *)
(fun () () -> Spec.Hash.Definitions.hash_length a) (* output_len *)
(fun () -> Hacl.Hash.Definitions.block_len a) (* block_len *)
(fun () -> Hacl.Hash.Definitions.block_len a) (* blocks_state_len *)
(fun () -> 0ul) (* init_input_len *)
(fun () _k -> S.empty) (* init_input_s *)
(* init_s *)
(fun () _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun () acc prevlen blocks -> update_multi_s a () acc prevlen blocks)
(* update_last_s *)
(fun () acc prevlen input -> Spec.Hash.Incremental.(update_last a acc prevlen input))
(* finish_s *)
(fun () _ acc () -> Spec.Agile.Hash.(finish a acc ()))
(* spec_s *)
(fun () _ s () -> Spec.Agile.Hash.(hash a s))
(* update_multi_zero *)
(fun i h prevlen -> update_multi_zero a i h prevlen)
(* update_multi_associative *)
(fun i acc prevlen1 prevlen2 input1 input2 -> update_multi_associative a i acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun _ key input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
(* index_of_state *)
(fun _ _ -> ())
(* init *)
(fun _ _ _ s ->
match a with
| MD5 -> Hacl.Hash.MD5.legacy_init s
| SHA1 -> Hacl.Hash.SHA1.legacy_init s
| SHA2_224 -> Hacl.Hash.SHA2.init_224 s
| SHA2_256 -> Hacl.Hash.SHA2.init_256 s
| SHA2_384 -> Hacl.Hash.SHA2.init_384 s
| SHA2_512 -> Hacl.Hash.SHA2.init_512 s
)
(* update_multi *)
(fun _ s prevlen blocks len ->
[@inline_let]
let update_multi : update_multi_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_update_multi
| SHA1 -> Hacl.Hash.SHA1.legacy_update_multi
| SHA2_224 -> Hacl.Hash.SHA2.update_multi_224
| SHA2_256 -> Hacl.Hash.SHA2.update_multi_256
| SHA2_384 -> Hacl.Hash.SHA2.update_multi_384
| SHA2_512 -> Hacl.Hash.SHA2.update_multi_512
in
update_multi s () blocks (len `U32.div` Hacl.Hash.Definitions.(block_len a)))
(* update_last *)
(fun _ s prevlen last last_len ->
[@inline_let]
let update_last : update_last_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_update_last
| SHA1 -> Hacl.Hash.SHA1.legacy_update_last
| SHA2_224 -> Hacl.Hash.SHA2.update_last_224
| SHA2_256 -> Hacl.Hash.SHA2.update_last_256
| SHA2_384 -> Hacl.Hash.SHA2.update_last_384
| SHA2_512 -> Hacl.Hash.SHA2.update_last_512
in
update_last s (md_prevlen a prevlen) last last_len)
(* finish *)
(fun _ _ s dst _ ->
[@inline_let]
let finish : finish_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_finish
| SHA1 -> Hacl.Hash.SHA1.legacy_finish
| SHA2_224 -> Hacl.Hash.SHA2.finish_224
| SHA2_256 -> Hacl.Hash.SHA2.finish_256
| SHA2_384 -> Hacl.Hash.SHA2.finish_384
| SHA2_512 -> Hacl.Hash.SHA2.finish_512
in
finish s dst)
#pop-options
// Putting some type abbreviations here, so that they appear in a separate file that can then be included by all streaming algorithms, rather than having e.g. SHA1 depend on e.g. MD5
// Could be anything that's 32-bit | false | true | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hacl_sha2_256 : Hacl.Streaming.Interface.block Prims.unit | [] | Hacl.Streaming.MD.hacl_sha2_256 | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Interface.block Prims.unit | {
"end_col": 36,
"end_line": 190,
"start_col": 20,
"start_line": 190
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let hacl_sha2_512 = hacl_md SHA2_512 | let hacl_sha2_512 = | false | null | false | hacl_md SHA2_512 | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.hacl_md",
"Spec.Hash.Definitions.SHA2_512"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Hash.Definitions
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
inline_for_extraction noextract
let alg = md_alg
inline_for_extraction noextract
let init_elem (a : alg) : word a =
match a with
| MD5 | SHA1 | SHA2_256 | SHA2_224 -> Lib.IntTypes.u32 0
| SHA2_384 | SHA2_512 -> Lib.IntTypes.u64 0
inline_for_extraction noextract
let state_t (a : alg) = stateful_buffer (word a) (D.impl_state_len (|a, ()|)) (init_elem a) unit
inline_for_extraction noextract
let update_multi_s (a : alg) () acc (prevlen : nat) input =
Agile.(update_multi a acc () input)
noextract
let update_multi_zero (a : alg) () acc (prevlen : nat) :
Lemma(update_multi_s a () acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
#push-options "--ifuel 1"
// TODO: this is the third copy of this lemma!! why?!
noextract
let update_multi_associative (a : alg) () acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
update_multi_s a () (update_multi_s a () acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a () acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let md_prevlen (a: alg) (len: D.(len: U64.t { U64.v len % U32.v (block_len a) = 0 })): D.prev_len_t a =
if a = SHA2_384 || a = SHA2_512 then FStar.Int.Cast.Full.uint64_to_uint128 len else len
/// This proof usually succeeds fast but we increase the rlimit for safety
#push-options "--z3rlimit 500 --ifuel 1"
inline_for_extraction noextract
let hacl_md (a:alg)// : block unit =
=
Block
Erased
(state_t a) (* state *)
(stateful_unused unit) (* key *)
unit
(fun () -> max_input_len64 a) (* max_input_len *)
(fun () () -> Spec.Hash.Definitions.hash_length a) (* output_len *)
(fun () -> Hacl.Hash.Definitions.block_len a) (* block_len *)
(fun () -> Hacl.Hash.Definitions.block_len a) (* blocks_state_len *)
(fun () -> 0ul) (* init_input_len *)
(fun () _k -> S.empty) (* init_input_s *)
(* init_s *)
(fun () _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun () acc prevlen blocks -> update_multi_s a () acc prevlen blocks)
(* update_last_s *)
(fun () acc prevlen input -> Spec.Hash.Incremental.(update_last a acc prevlen input))
(* finish_s *)
(fun () _ acc () -> Spec.Agile.Hash.(finish a acc ()))
(* spec_s *)
(fun () _ s () -> Spec.Agile.Hash.(hash a s))
(* update_multi_zero *)
(fun i h prevlen -> update_multi_zero a i h prevlen)
(* update_multi_associative *)
(fun i acc prevlen1 prevlen2 input1 input2 -> update_multi_associative a i acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun _ key input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
(* index_of_state *)
(fun _ _ -> ())
(* init *)
(fun _ _ _ s ->
match a with
| MD5 -> Hacl.Hash.MD5.legacy_init s
| SHA1 -> Hacl.Hash.SHA1.legacy_init s
| SHA2_224 -> Hacl.Hash.SHA2.init_224 s
| SHA2_256 -> Hacl.Hash.SHA2.init_256 s
| SHA2_384 -> Hacl.Hash.SHA2.init_384 s
| SHA2_512 -> Hacl.Hash.SHA2.init_512 s
)
(* update_multi *)
(fun _ s prevlen blocks len ->
[@inline_let]
let update_multi : update_multi_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_update_multi
| SHA1 -> Hacl.Hash.SHA1.legacy_update_multi
| SHA2_224 -> Hacl.Hash.SHA2.update_multi_224
| SHA2_256 -> Hacl.Hash.SHA2.update_multi_256
| SHA2_384 -> Hacl.Hash.SHA2.update_multi_384
| SHA2_512 -> Hacl.Hash.SHA2.update_multi_512
in
update_multi s () blocks (len `U32.div` Hacl.Hash.Definitions.(block_len a)))
(* update_last *)
(fun _ s prevlen last last_len ->
[@inline_let]
let update_last : update_last_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_update_last
| SHA1 -> Hacl.Hash.SHA1.legacy_update_last
| SHA2_224 -> Hacl.Hash.SHA2.update_last_224
| SHA2_256 -> Hacl.Hash.SHA2.update_last_256
| SHA2_384 -> Hacl.Hash.SHA2.update_last_384
| SHA2_512 -> Hacl.Hash.SHA2.update_last_512
in
update_last s (md_prevlen a prevlen) last last_len)
(* finish *)
(fun _ _ s dst _ ->
[@inline_let]
let finish : finish_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_finish
| SHA1 -> Hacl.Hash.SHA1.legacy_finish
| SHA2_224 -> Hacl.Hash.SHA2.finish_224
| SHA2_256 -> Hacl.Hash.SHA2.finish_256
| SHA2_384 -> Hacl.Hash.SHA2.finish_384
| SHA2_512 -> Hacl.Hash.SHA2.finish_512
in
finish s dst)
#pop-options
// Putting some type abbreviations here, so that they appear in a separate file that can then be included by all streaming algorithms, rather than having e.g. SHA1 depend on e.g. MD5
// Could be anything that's 32-bit
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
let state_32 = F.state_s hacl_sha2_256 () ((state_t SHA2_256).s ()) (G.erased unit) | false | true | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val hacl_sha2_512 : Hacl.Streaming.Interface.block Prims.unit | [] | Hacl.Streaming.MD.hacl_sha2_512 | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Streaming.Interface.block Prims.unit | {
"end_col": 36,
"end_line": 195,
"start_col": 20,
"start_line": 195
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_multi_s (a : alg) () acc (prevlen : nat) input =
Agile.(update_multi a acc () input) | let update_multi_s (a: alg) () acc (prevlen: nat) input = | false | null | false | let open Agile in update_multi a acc () input | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.alg",
"Prims.unit",
"Spec.Hash.Definitions.words_state",
"Prims.nat",
"Spec.Hash.Definitions.bytes_blocks",
"Spec.Agile.Hash.update_multi"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Hash.Definitions
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
inline_for_extraction noextract
let alg = md_alg
inline_for_extraction noextract
let init_elem (a : alg) : word a =
match a with
| MD5 | SHA1 | SHA2_256 | SHA2_224 -> Lib.IntTypes.u32 0
| SHA2_384 | SHA2_512 -> Lib.IntTypes.u64 0
inline_for_extraction noextract
let state_t (a : alg) = stateful_buffer (word a) (D.impl_state_len (|a, ()|)) (init_elem a) unit
inline_for_extraction noextract | false | false | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_multi_s : a: Hacl.Streaming.MD.alg ->
_: Prims.unit ->
acc: Spec.Hash.Definitions.words_state a ->
prevlen: Prims.nat ->
input: Spec.Hash.Definitions.bytes_blocks a
-> Spec.Hash.Definitions.words_state a | [] | Hacl.Streaming.MD.update_multi_s | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Hacl.Streaming.MD.alg ->
_: Prims.unit ->
acc: Spec.Hash.Definitions.words_state a ->
prevlen: Prims.nat ->
input: Spec.Hash.Definitions.bytes_blocks a
-> Spec.Hash.Definitions.words_state a | {
"end_col": 37,
"end_line": 54,
"start_col": 2,
"start_line": 54
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let state_64 = F.state_s hacl_sha2_512 () ((state_t SHA2_512).s ()) (G.erased unit) | let state_64 = | false | null | false | F.state_s hacl_sha2_512 () ((state_t SHA2_512).s ()) (G.erased unit) | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.state_s",
"Prims.unit",
"Hacl.Streaming.MD.hacl_sha2_512",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.MD.state_t",
"Spec.Hash.Definitions.SHA2_512",
"FStar.Ghost.erased"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Hash.Definitions
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
inline_for_extraction noextract
let alg = md_alg
inline_for_extraction noextract
let init_elem (a : alg) : word a =
match a with
| MD5 | SHA1 | SHA2_256 | SHA2_224 -> Lib.IntTypes.u32 0
| SHA2_384 | SHA2_512 -> Lib.IntTypes.u64 0
inline_for_extraction noextract
let state_t (a : alg) = stateful_buffer (word a) (D.impl_state_len (|a, ()|)) (init_elem a) unit
inline_for_extraction noextract
let update_multi_s (a : alg) () acc (prevlen : nat) input =
Agile.(update_multi a acc () input)
noextract
let update_multi_zero (a : alg) () acc (prevlen : nat) :
Lemma(update_multi_s a () acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
#push-options "--ifuel 1"
// TODO: this is the third copy of this lemma!! why?!
noextract
let update_multi_associative (a : alg) () acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
update_multi_s a () (update_multi_s a () acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a () acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let md_prevlen (a: alg) (len: D.(len: U64.t { U64.v len % U32.v (block_len a) = 0 })): D.prev_len_t a =
if a = SHA2_384 || a = SHA2_512 then FStar.Int.Cast.Full.uint64_to_uint128 len else len
/// This proof usually succeeds fast but we increase the rlimit for safety
#push-options "--z3rlimit 500 --ifuel 1"
inline_for_extraction noextract
let hacl_md (a:alg)// : block unit =
=
Block
Erased
(state_t a) (* state *)
(stateful_unused unit) (* key *)
unit
(fun () -> max_input_len64 a) (* max_input_len *)
(fun () () -> Spec.Hash.Definitions.hash_length a) (* output_len *)
(fun () -> Hacl.Hash.Definitions.block_len a) (* block_len *)
(fun () -> Hacl.Hash.Definitions.block_len a) (* blocks_state_len *)
(fun () -> 0ul) (* init_input_len *)
(fun () _k -> S.empty) (* init_input_s *)
(* init_s *)
(fun () _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun () acc prevlen blocks -> update_multi_s a () acc prevlen blocks)
(* update_last_s *)
(fun () acc prevlen input -> Spec.Hash.Incremental.(update_last a acc prevlen input))
(* finish_s *)
(fun () _ acc () -> Spec.Agile.Hash.(finish a acc ()))
(* spec_s *)
(fun () _ s () -> Spec.Agile.Hash.(hash a s))
(* update_multi_zero *)
(fun i h prevlen -> update_multi_zero a i h prevlen)
(* update_multi_associative *)
(fun i acc prevlen1 prevlen2 input1 input2 -> update_multi_associative a i acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun _ key input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
(* index_of_state *)
(fun _ _ -> ())
(* init *)
(fun _ _ _ s ->
match a with
| MD5 -> Hacl.Hash.MD5.legacy_init s
| SHA1 -> Hacl.Hash.SHA1.legacy_init s
| SHA2_224 -> Hacl.Hash.SHA2.init_224 s
| SHA2_256 -> Hacl.Hash.SHA2.init_256 s
| SHA2_384 -> Hacl.Hash.SHA2.init_384 s
| SHA2_512 -> Hacl.Hash.SHA2.init_512 s
)
(* update_multi *)
(fun _ s prevlen blocks len ->
[@inline_let]
let update_multi : update_multi_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_update_multi
| SHA1 -> Hacl.Hash.SHA1.legacy_update_multi
| SHA2_224 -> Hacl.Hash.SHA2.update_multi_224
| SHA2_256 -> Hacl.Hash.SHA2.update_multi_256
| SHA2_384 -> Hacl.Hash.SHA2.update_multi_384
| SHA2_512 -> Hacl.Hash.SHA2.update_multi_512
in
update_multi s () blocks (len `U32.div` Hacl.Hash.Definitions.(block_len a)))
(* update_last *)
(fun _ s prevlen last last_len ->
[@inline_let]
let update_last : update_last_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_update_last
| SHA1 -> Hacl.Hash.SHA1.legacy_update_last
| SHA2_224 -> Hacl.Hash.SHA2.update_last_224
| SHA2_256 -> Hacl.Hash.SHA2.update_last_256
| SHA2_384 -> Hacl.Hash.SHA2.update_last_384
| SHA2_512 -> Hacl.Hash.SHA2.update_last_512
in
update_last s (md_prevlen a prevlen) last last_len)
(* finish *)
(fun _ _ s dst _ ->
[@inline_let]
let finish : finish_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_finish
| SHA1 -> Hacl.Hash.SHA1.legacy_finish
| SHA2_224 -> Hacl.Hash.SHA2.finish_224
| SHA2_256 -> Hacl.Hash.SHA2.finish_256
| SHA2_384 -> Hacl.Hash.SHA2.finish_384
| SHA2_512 -> Hacl.Hash.SHA2.finish_512
in
finish s dst)
#pop-options
// Putting some type abbreviations here, so that they appear in a separate file that can then be included by all streaming algorithms, rather than having e.g. SHA1 depend on e.g. MD5
// Could be anything that's 32-bit
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256
let state_32 = F.state_s hacl_sha2_256 () ((state_t SHA2_256).s ()) (G.erased unit)
inline_for_extraction noextract
let hacl_sha2_512 = hacl_md SHA2_512 | false | true | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val state_64 : Type0 | [] | Hacl.Streaming.MD.state_64 | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 83,
"end_line": 197,
"start_col": 15,
"start_line": 197
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let state_32 = F.state_s hacl_sha2_256 () ((state_t SHA2_256).s ()) (G.erased unit) | let state_32 = | false | null | false | F.state_s hacl_sha2_256 () ((state_t SHA2_256).s ()) (G.erased unit) | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Hacl.Streaming.Functor.state_s",
"Prims.unit",
"Hacl.Streaming.MD.hacl_sha2_256",
"Hacl.Streaming.Interface.__proj__Stateful__item__s",
"Hacl.Streaming.MD.state_t",
"Spec.Hash.Definitions.SHA2_256",
"FStar.Ghost.erased"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Hash.Definitions
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
inline_for_extraction noextract
let alg = md_alg
inline_for_extraction noextract
let init_elem (a : alg) : word a =
match a with
| MD5 | SHA1 | SHA2_256 | SHA2_224 -> Lib.IntTypes.u32 0
| SHA2_384 | SHA2_512 -> Lib.IntTypes.u64 0
inline_for_extraction noextract
let state_t (a : alg) = stateful_buffer (word a) (D.impl_state_len (|a, ()|)) (init_elem a) unit
inline_for_extraction noextract
let update_multi_s (a : alg) () acc (prevlen : nat) input =
Agile.(update_multi a acc () input)
noextract
let update_multi_zero (a : alg) () acc (prevlen : nat) :
Lemma(update_multi_s a () acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc
#push-options "--ifuel 1"
// TODO: this is the third copy of this lemma!! why?!
noextract
let update_multi_associative (a : alg) () acc (prevlen1 prevlen2 : nat)
(input1 input2 : S.seq uint8) :
Lemma
(requires (
S.length input1 % U32.v (D.block_len a) = 0 /\
S.length input2 % U32.v (D.block_len a) = 0))
(ensures (
let input = S.append input1 input2 in
S.length input % U32.v (D.block_len a) = 0 /\
update_multi_s a () (update_multi_s a () acc prevlen1 input1) prevlen2 input2 ==
update_multi_s a () acc prevlen1 input)) =
Spec.Hash.Lemmas.update_multi_associative a acc input1 input2
#pop-options
inline_for_extraction noextract
let md_prevlen (a: alg) (len: D.(len: U64.t { U64.v len % U32.v (block_len a) = 0 })): D.prev_len_t a =
if a = SHA2_384 || a = SHA2_512 then FStar.Int.Cast.Full.uint64_to_uint128 len else len
/// This proof usually succeeds fast but we increase the rlimit for safety
#push-options "--z3rlimit 500 --ifuel 1"
inline_for_extraction noextract
let hacl_md (a:alg)// : block unit =
=
Block
Erased
(state_t a) (* state *)
(stateful_unused unit) (* key *)
unit
(fun () -> max_input_len64 a) (* max_input_len *)
(fun () () -> Spec.Hash.Definitions.hash_length a) (* output_len *)
(fun () -> Hacl.Hash.Definitions.block_len a) (* block_len *)
(fun () -> Hacl.Hash.Definitions.block_len a) (* blocks_state_len *)
(fun () -> 0ul) (* init_input_len *)
(fun () _k -> S.empty) (* init_input_s *)
(* init_s *)
(fun () _ -> Spec.Agile.Hash.init a)
(* update_multi_s *)
(fun () acc prevlen blocks -> update_multi_s a () acc prevlen blocks)
(* update_last_s *)
(fun () acc prevlen input -> Spec.Hash.Incremental.(update_last a acc prevlen input))
(* finish_s *)
(fun () _ acc () -> Spec.Agile.Hash.(finish a acc ()))
(* spec_s *)
(fun () _ s () -> Spec.Agile.Hash.(hash a s))
(* update_multi_zero *)
(fun i h prevlen -> update_multi_zero a i h prevlen)
(* update_multi_associative *)
(fun i acc prevlen1 prevlen2 input1 input2 -> update_multi_associative a i acc prevlen1 prevlen2 input1 input2)
(* spec_is_incremental *)
(fun _ key input () ->
let input1 = S.append S.empty input in
assert (S.equal input1 input);
Spec.Hash.Incremental.hash_is_hash_incremental' a input ())
(* index_of_state *)
(fun _ _ -> ())
(* init *)
(fun _ _ _ s ->
match a with
| MD5 -> Hacl.Hash.MD5.legacy_init s
| SHA1 -> Hacl.Hash.SHA1.legacy_init s
| SHA2_224 -> Hacl.Hash.SHA2.init_224 s
| SHA2_256 -> Hacl.Hash.SHA2.init_256 s
| SHA2_384 -> Hacl.Hash.SHA2.init_384 s
| SHA2_512 -> Hacl.Hash.SHA2.init_512 s
)
(* update_multi *)
(fun _ s prevlen blocks len ->
[@inline_let]
let update_multi : update_multi_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_update_multi
| SHA1 -> Hacl.Hash.SHA1.legacy_update_multi
| SHA2_224 -> Hacl.Hash.SHA2.update_multi_224
| SHA2_256 -> Hacl.Hash.SHA2.update_multi_256
| SHA2_384 -> Hacl.Hash.SHA2.update_multi_384
| SHA2_512 -> Hacl.Hash.SHA2.update_multi_512
in
update_multi s () blocks (len `U32.div` Hacl.Hash.Definitions.(block_len a)))
(* update_last *)
(fun _ s prevlen last last_len ->
[@inline_let]
let update_last : update_last_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_update_last
| SHA1 -> Hacl.Hash.SHA1.legacy_update_last
| SHA2_224 -> Hacl.Hash.SHA2.update_last_224
| SHA2_256 -> Hacl.Hash.SHA2.update_last_256
| SHA2_384 -> Hacl.Hash.SHA2.update_last_384
| SHA2_512 -> Hacl.Hash.SHA2.update_last_512
in
update_last s (md_prevlen a prevlen) last last_len)
(* finish *)
(fun _ _ s dst _ ->
[@inline_let]
let finish : finish_st (|a,()|) =
match a with
| MD5 -> Hacl.Hash.MD5.legacy_finish
| SHA1 -> Hacl.Hash.SHA1.legacy_finish
| SHA2_224 -> Hacl.Hash.SHA2.finish_224
| SHA2_256 -> Hacl.Hash.SHA2.finish_256
| SHA2_384 -> Hacl.Hash.SHA2.finish_384
| SHA2_512 -> Hacl.Hash.SHA2.finish_512
in
finish s dst)
#pop-options
// Putting some type abbreviations here, so that they appear in a separate file that can then be included by all streaming algorithms, rather than having e.g. SHA1 depend on e.g. MD5
// Could be anything that's 32-bit
inline_for_extraction noextract
let hacl_sha2_256 = hacl_md SHA2_256 | false | true | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val state_32 : Type0 | [] | Hacl.Streaming.MD.state_32 | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 83,
"end_line": 192,
"start_col": 15,
"start_line": 192
} |
|
Prims.Tot | val init_elem (a: alg) : word a | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let init_elem (a : alg) : word a =
match a with
| MD5 | SHA1 | SHA2_256 | SHA2_224 -> Lib.IntTypes.u32 0
| SHA2_384 | SHA2_512 -> Lib.IntTypes.u64 0 | val init_elem (a: alg) : word a
let init_elem (a: alg) : word a = | false | null | false | match a with
| MD5 | SHA1 | SHA2_256 | SHA2_224 -> Lib.IntTypes.u32 0
| SHA2_384 | SHA2_512 -> Lib.IntTypes.u64 0 | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.alg",
"Lib.IntTypes.u32",
"Lib.IntTypes.u64",
"Spec.Hash.Definitions.word"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Hash.Definitions
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
inline_for_extraction noextract
let alg = md_alg
inline_for_extraction noextract | false | false | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val init_elem (a: alg) : word a | [] | Hacl.Streaming.MD.init_elem | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Streaming.MD.alg -> Spec.Hash.Definitions.word a | {
"end_col": 45,
"end_line": 47,
"start_col": 2,
"start_line": 45
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let state_t (a : alg) = stateful_buffer (word a) (D.impl_state_len (|a, ()|)) (init_elem a) unit | let state_t (a: alg) = | false | null | false | stateful_buffer (word a) (D.impl_state_len (| a, () |)) (init_elem a) unit | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"total"
] | [
"Hacl.Streaming.MD.alg",
"Hacl.Streaming.Interface.stateful_buffer",
"Spec.Hash.Definitions.word",
"Hacl.Hash.Definitions.impl_state_len",
"Prims.Mkdtuple2",
"Spec.Hash.Definitions.hash_alg",
"Hacl.Hash.Definitions.m_spec",
"Hacl.Streaming.MD.init_elem",
"Prims.unit",
"Hacl.Streaming.Interface.stateful"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Hash.Definitions
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
inline_for_extraction noextract
let alg = md_alg
inline_for_extraction noextract
let init_elem (a : alg) : word a =
match a with
| MD5 | SHA1 | SHA2_256 | SHA2_224 -> Lib.IntTypes.u32 0
| SHA2_384 | SHA2_512 -> Lib.IntTypes.u64 0 | false | true | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val state_t : a: Hacl.Streaming.MD.alg -> Hacl.Streaming.Interface.stateful Prims.unit | [] | Hacl.Streaming.MD.state_t | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Hacl.Streaming.MD.alg -> Hacl.Streaming.Interface.stateful Prims.unit | {
"end_col": 96,
"end_line": 50,
"start_col": 24,
"start_line": 50
} |
|
FStar.Pervasives.Lemma | val update_multi_zero: a: alg -> Prims.unit -> acc: _ -> prevlen: nat
-> Lemma (update_multi_s a () acc prevlen S.empty == acc) | [
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Agile"
},
{
"abbrev": true,
"full_module": "Hacl.Hash.Definitions",
"short_module": "D"
},
{
"abbrev": false,
"full_module": "Hacl.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming.Interface",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Hash.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.BufferOps",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Hacl.Streaming.Functor",
"short_module": "F"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "G"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Streaming",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let update_multi_zero (a : alg) () acc (prevlen : nat) :
Lemma(update_multi_s a () acc prevlen S.empty == acc) = Spec.Hash.Lemmas.update_multi_zero a acc | val update_multi_zero: a: alg -> Prims.unit -> acc: _ -> prevlen: nat
-> Lemma (update_multi_s a () acc prevlen S.empty == acc)
let update_multi_zero (a: alg) () acc (prevlen: nat)
: Lemma (update_multi_s a () acc prevlen S.empty == acc) = | false | null | true | Spec.Hash.Lemmas.update_multi_zero a acc | {
"checked_file": "Hacl.Streaming.MD.fst.checked",
"dependencies": [
"Spec.Hash.Lemmas.fsti.checked",
"Spec.Hash.Incremental.fsti.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"LowStar.BufferOps.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"Hacl.Streaming.Interface.fsti.checked",
"Hacl.Streaming.Functor.fsti.checked",
"Hacl.Hash.SHA2.fsti.checked",
"Hacl.Hash.SHA1.fsti.checked",
"Hacl.Hash.MD5.fsti.checked",
"Hacl.Hash.Definitions.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Int.Cast.Full.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Streaming.MD.fst"
} | [
"lemma"
] | [
"Hacl.Streaming.MD.alg",
"Prims.unit",
"Spec.Hash.Definitions.words_state",
"Prims.nat",
"Spec.Hash.Lemmas.update_multi_zero",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"Hacl.Streaming.MD.update_multi_s",
"FStar.Seq.Base.empty",
"Lib.IntTypes.uint8",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Hacl.Streaming.MD
open FStar.HyperStack.ST
/// This file is poorly named. It contains a generic type class instantiation
/// for the streaming functor for any algorithm that fits within the agile hash
/// infrastructure.
#set-options "--max_fuel 0 --max_ifuel 0 --z3rlimit 100"
module HS = FStar.HyperStack
module B = LowStar.Buffer
module G = FStar.Ghost
module S = FStar.Seq
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module F = Hacl.Streaming.Functor
module ST = FStar.HyperStack.ST
open LowStar.BufferOps
open FStar.Mul
inline_for_extraction noextract
let uint8 = Lib.IntTypes.uint8
inline_for_extraction noextract
let uint32 = Lib.IntTypes.uint32
open Spec.Hash.Definitions
open Hacl.Streaming.Interface
open Hacl.Hash.Definitions
module D = Hacl.Hash.Definitions
module Agile = Spec.Agile.Hash
let _: squash (inversion hash_alg) = allow_inversion hash_alg
inline_for_extraction noextract
let alg = md_alg
inline_for_extraction noextract
let init_elem (a : alg) : word a =
match a with
| MD5 | SHA1 | SHA2_256 | SHA2_224 -> Lib.IntTypes.u32 0
| SHA2_384 | SHA2_512 -> Lib.IntTypes.u64 0
inline_for_extraction noextract
let state_t (a : alg) = stateful_buffer (word a) (D.impl_state_len (|a, ()|)) (init_elem a) unit
inline_for_extraction noextract
let update_multi_s (a : alg) () acc (prevlen : nat) input =
Agile.(update_multi a acc () input)
noextract | false | false | Hacl.Streaming.MD.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val update_multi_zero: a: alg -> Prims.unit -> acc: _ -> prevlen: nat
-> Lemma (update_multi_s a () acc prevlen S.empty == acc) | [] | Hacl.Streaming.MD.update_multi_zero | {
"file_name": "code/streaming/Hacl.Streaming.MD.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Hacl.Streaming.MD.alg ->
_: Prims.unit ->
acc: Spec.Hash.Definitions.words_state a ->
prevlen: Prims.nat
-> FStar.Pervasives.Lemma
(ensures Hacl.Streaming.MD.update_multi_s a () acc prevlen FStar.Seq.Base.empty == acc) | {
"end_col": 98,
"end_line": 58,
"start_col": 58,
"start_line": 58
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.