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.Pervasives.Lemma | val get_hkeys_reqs_injective (h_BE:quad32) (s1 s2:Seq.seq quad32) : Lemma
(requires
Seq.length s1 = 8 /\ Seq.length s2 = 8 /\
hkeys_reqs_pub s1 h_BE /\ hkeys_reqs_pub s2 h_BE)
(ensures s1 == s2) | [
{
"abbrev": false,
"full_module": "FStar.UInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_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": "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 get_hkeys_reqs_injective h_BE s1 s2 =
lemma_of_quad32_inj (Seq.index s1 0) (Seq.index s2 0);
lemma_of_quad32_inj (Seq.index s1 1) (Seq.index s2 1);
lemma_of_quad32_inj (Seq.index s1 3) (Seq.index s2 3);
lemma_of_quad32_inj (Seq.index s1 4) (Seq.index s2 4);
lemma_of_quad32_inj (Seq.index s1 6) (Seq.index s2 6);
lemma_of_quad32_inj (Seq.index s1 7) (Seq.index s2 7);
assert (Seq.equal s1 s2) | val get_hkeys_reqs_injective (h_BE:quad32) (s1 s2:Seq.seq quad32) : Lemma
(requires
Seq.length s1 = 8 /\ Seq.length s2 = 8 /\
hkeys_reqs_pub s1 h_BE /\ hkeys_reqs_pub s2 h_BE)
(ensures s1 == s2)
let get_hkeys_reqs_injective h_BE s1 s2 = | false | null | true | lemma_of_quad32_inj (Seq.index s1 0) (Seq.index s2 0);
lemma_of_quad32_inj (Seq.index s1 1) (Seq.index s2 1);
lemma_of_quad32_inj (Seq.index s1 3) (Seq.index s2 3);
lemma_of_quad32_inj (Seq.index s1 4) (Seq.index s2 4);
lemma_of_quad32_inj (Seq.index s1 6) (Seq.index s2 6);
lemma_of_quad32_inj (Seq.index s1 7) (Seq.index s2 7);
assert (Seq.equal s1 s2) | {
"checked_file": "Vale.AES.OptPublic.fst.checked",
"dependencies": [
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Vale.AES.OptPublic.fst"
} | [
"lemma"
] | [
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Prims._assert",
"FStar.Seq.Base.equal",
"Prims.unit",
"Vale.AES.OptPublic.lemma_of_quad32_inj",
"FStar.Seq.Base.index"
] | [] | module Vale.AES.OptPublic
open FStar.Mul
open FStar.Seq
open Vale.Def.Types_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Def.Words_s
let shift_gf128_key_1 (h:poly) : poly =
shift_key_1 128 gf128_modulus_low_terms h
let rec g_power (a:poly) (n:nat) : poly =
if n = 0 then zero else // arbitrary value for n = 0
if n = 1 then a else
a *~ g_power a (n - 1)
let gf128_power (h:poly) (n:nat) : poly = shift_gf128_key_1 (g_power h n)
let hkeys_reqs_pub (hkeys:seq quad32) (h_BE:quad32) : Vale.Def.Prop_s.prop0
=
let h = of_quad32 (reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)) in
length hkeys >= 8 /\
of_quad32 (index hkeys 0) == gf128_power h 1 /\
of_quad32 (index hkeys 1) == gf128_power h 2 /\
index hkeys 2 == h_BE /\
of_quad32 (index hkeys 3) == gf128_power h 3 /\
of_quad32 (index hkeys 4) == gf128_power h 4 /\
index hkeys 5 == Mkfour 0 0 0 0 /\ // Not needed but we want injectivity
of_quad32 (index hkeys 6) == gf128_power h 5 /\
of_quad32 (index hkeys 7) == gf128_power h 6
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
open FStar.List.Tot
open Vale.Math.Poly2.Bits
let get_hkeys_reqs h_BE =
let h = of_quad32 (reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)) in
let l = [to_quad32 (gf128_power h 1);
to_quad32 (gf128_power h 2);
h_BE;
to_quad32 (gf128_power h 3);
to_quad32 (gf128_power h 4);
Mkfour 0 0 0 0;
to_quad32 (gf128_power h 5);
to_quad32 (gf128_power h 6)] in
assert_norm (length l = 8);
let s = Seq.seq_of_list l in
Seq.lemma_seq_of_list_induction l;
Seq.lemma_seq_of_list_induction (tl l);
Seq.lemma_seq_of_list_induction (tl (tl l));
Seq.lemma_seq_of_list_induction (tl (tl (tl l)));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl l))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl l)))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl l))))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl (tl l)))))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl (tl (tl l))))))));
lemma_of_to_quad32 (gf128_power h 1);
lemma_of_to_quad32 (gf128_power h 2);
lemma_of_to_quad32 (gf128_power h 3);
lemma_of_to_quad32 (gf128_power h 4);
lemma_of_to_quad32 (gf128_power h 5);
lemma_of_to_quad32 (gf128_power h 6);
assert (hkeys_reqs_pub s h_BE);
s
open FStar.UInt
let lemma_of_quad32_inj (q q':quad32) : Lemma
(requires of_quad32 q == of_quad32 q')
(ensures q == q')
= lemma_to_of_quad32 q; lemma_to_of_quad32 q' | false | false | Vale.AES.OptPublic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_hkeys_reqs_injective (h_BE:quad32) (s1 s2:Seq.seq quad32) : Lemma
(requires
Seq.length s1 = 8 /\ Seq.length s2 = 8 /\
hkeys_reqs_pub s1 h_BE /\ hkeys_reqs_pub s2 h_BE)
(ensures s1 == s2) | [] | Vale.AES.OptPublic.get_hkeys_reqs_injective | {
"file_name": "vale/code/crypto/aes/Vale.AES.OptPublic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
h_BE: Vale.Def.Types_s.quad32 ->
s1: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
s2: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> FStar.Pervasives.Lemma
(requires
FStar.Seq.Base.length s1 = 8 /\ FStar.Seq.Base.length s2 = 8 /\
Vale.AES.OptPublic.hkeys_reqs_pub s1 h_BE /\ Vale.AES.OptPublic.hkeys_reqs_pub s2 h_BE)
(ensures s1 == s2) | {
"end_col": 26,
"end_line": 84,
"start_col": 2,
"start_line": 78
} |
Prims.Tot | val get_hkeys_reqs (h_BE:quad32) : (s:Seq.lseq quad32 8{hkeys_reqs_pub s h_BE}) | [
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2_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": "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 get_hkeys_reqs h_BE =
let h = of_quad32 (reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)) in
let l = [to_quad32 (gf128_power h 1);
to_quad32 (gf128_power h 2);
h_BE;
to_quad32 (gf128_power h 3);
to_quad32 (gf128_power h 4);
Mkfour 0 0 0 0;
to_quad32 (gf128_power h 5);
to_quad32 (gf128_power h 6)] in
assert_norm (length l = 8);
let s = Seq.seq_of_list l in
Seq.lemma_seq_of_list_induction l;
Seq.lemma_seq_of_list_induction (tl l);
Seq.lemma_seq_of_list_induction (tl (tl l));
Seq.lemma_seq_of_list_induction (tl (tl (tl l)));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl l))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl l)))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl l))))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl (tl l)))))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl (tl (tl l))))))));
lemma_of_to_quad32 (gf128_power h 1);
lemma_of_to_quad32 (gf128_power h 2);
lemma_of_to_quad32 (gf128_power h 3);
lemma_of_to_quad32 (gf128_power h 4);
lemma_of_to_quad32 (gf128_power h 5);
lemma_of_to_quad32 (gf128_power h 6);
assert (hkeys_reqs_pub s h_BE);
s | val get_hkeys_reqs (h_BE:quad32) : (s:Seq.lseq quad32 8{hkeys_reqs_pub s h_BE})
let get_hkeys_reqs h_BE = | false | null | false | let h = of_quad32 (reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)) in
let l =
[
to_quad32 (gf128_power h 1);
to_quad32 (gf128_power h 2);
h_BE;
to_quad32 (gf128_power h 3);
to_quad32 (gf128_power h 4);
Mkfour 0 0 0 0;
to_quad32 (gf128_power h 5);
to_quad32 (gf128_power h 6)
]
in
assert_norm (length l = 8);
let s = Seq.seq_of_list l in
Seq.lemma_seq_of_list_induction l;
Seq.lemma_seq_of_list_induction (tl l);
Seq.lemma_seq_of_list_induction (tl (tl l));
Seq.lemma_seq_of_list_induction (tl (tl (tl l)));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl l))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl l)))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl l))))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl (tl l)))))));
Seq.lemma_seq_of_list_induction (tl (tl (tl (tl (tl (tl (tl (tl l))))))));
lemma_of_to_quad32 (gf128_power h 1);
lemma_of_to_quad32 (gf128_power h 2);
lemma_of_to_quad32 (gf128_power h 3);
lemma_of_to_quad32 (gf128_power h 4);
lemma_of_to_quad32 (gf128_power h 5);
lemma_of_to_quad32 (gf128_power h 6);
assert (hkeys_reqs_pub s h_BE);
s | {
"checked_file": "Vale.AES.OptPublic.fst.checked",
"dependencies": [
"Vale.Math.Poly2_s.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Math.Poly2.Bits.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Vale.AES.OptPublic.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Prims.unit",
"Prims._assert",
"Vale.AES.OptPublic.hkeys_reqs_pub",
"Vale.Math.Poly2.Bits.lemma_of_to_quad32",
"Vale.AES.OptPublic.gf128_power",
"FStar.Seq.Properties.lemma_seq_of_list_induction",
"FStar.List.Tot.Base.tl",
"FStar.Seq.Base.seq",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.length",
"FStar.Seq.Properties.seq_of_list",
"FStar.Pervasives.assert_norm",
"Prims.int",
"Prims.list",
"Prims.Cons",
"Vale.Math.Poly2.Bits_s.to_quad32",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Prims.Nil",
"Vale.Math.Poly2_s.poly",
"Vale.Math.Poly2.Bits_s.of_quad32",
"Vale.Def.Types_s.reverse_bytes_quad32",
"FStar.Seq.Properties.lseq"
] | [] | module Vale.AES.OptPublic
open FStar.Mul
open FStar.Seq
open Vale.Def.Types_s
open Vale.Math.Poly2_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Def.Words_s
let shift_gf128_key_1 (h:poly) : poly =
shift_key_1 128 gf128_modulus_low_terms h
let rec g_power (a:poly) (n:nat) : poly =
if n = 0 then zero else // arbitrary value for n = 0
if n = 1 then a else
a *~ g_power a (n - 1)
let gf128_power (h:poly) (n:nat) : poly = shift_gf128_key_1 (g_power h n)
let hkeys_reqs_pub (hkeys:seq quad32) (h_BE:quad32) : Vale.Def.Prop_s.prop0
=
let h = of_quad32 (reverse_bytes_quad32 (reverse_bytes_quad32 h_BE)) in
length hkeys >= 8 /\
of_quad32 (index hkeys 0) == gf128_power h 1 /\
of_quad32 (index hkeys 1) == gf128_power h 2 /\
index hkeys 2 == h_BE /\
of_quad32 (index hkeys 3) == gf128_power h 3 /\
of_quad32 (index hkeys 4) == gf128_power h 4 /\
index hkeys 5 == Mkfour 0 0 0 0 /\ // Not needed but we want injectivity
of_quad32 (index hkeys 6) == gf128_power h 5 /\
of_quad32 (index hkeys 7) == gf128_power h 6
#set-options "--z3rlimit 20 --max_fuel 0 --max_ifuel 0"
open FStar.List.Tot
open Vale.Math.Poly2.Bits | false | false | Vale.AES.OptPublic.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"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": 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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val get_hkeys_reqs (h_BE:quad32) : (s:Seq.lseq quad32 8{hkeys_reqs_pub s h_BE}) | [] | Vale.AES.OptPublic.get_hkeys_reqs | {
"file_name": "vale/code/crypto/aes/Vale.AES.OptPublic.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | h_BE: Vale.Def.Types_s.quad32
-> s:
FStar.Seq.Properties.lseq Vale.Def.Types_s.quad32 8 {Vale.AES.OptPublic.hkeys_reqs_pub s h_BE} | {
"end_col": 3,
"end_line": 68,
"start_col": 25,
"start_line": 40
} |
Prims.GTot | val frameOf (#a: typ) (b: buffer a) : GTot HH.rid | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b | val frameOf (#a: typ) (b: buffer a) : GTot HH.rid
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid = | false | null | false | P.frameOf_buffer b | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.frameOf_buffer",
"FStar.Monotonic.HyperHeap.rid"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold | false | false | FStar.BufferNG.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 frameOf (#a: typ) (b: buffer a) : GTot HH.rid | [] | FStar.BufferNG.frameOf | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> Prims.GTot FStar.Monotonic.HyperHeap.rid | {
"end_col": 20,
"end_line": 69,
"start_col": 2,
"start_line": 69
} |
Prims.GTot | val disjoint (#a #a': typ) (x: buffer a) (y: buffer a') : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y) | val disjoint (#a #a': typ) (x: buffer a) (y: buffer a') : GTot Type0
let disjoint (#a #a': typ) (x: buffer a) (y: buffer a') : GTot Type0 = | false | null | false | P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.loc_disjoint",
"FStar.Pointer.Base.loc_buffer"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold | false | false | FStar.BufferNG.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 disjoint (#a #a': typ) (x: buffer a) (y: buffer a') : GTot Type0 | [] | FStar.BufferNG.disjoint | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.BufferNG.buffer a -> y: FStar.BufferNG.buffer a' -> Prims.GTot Type0 | {
"end_col": 50,
"end_line": 109,
"start_col": 2,
"start_line": 109
} |
Prims.GTot | val unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h | val unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 = | false | null | false | P.buffer_unused_in b h | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.Monotonic.HyperStack.mem",
"FStar.Pointer.Base.buffer_unused_in"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold | false | false | FStar.BufferNG.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 unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 | [] | FStar.BufferNG.unused_in | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> h: FStar.Monotonic.HyperStack.mem -> Prims.GTot Type0 | {
"end_col": 24,
"end_line": 57,
"start_col": 2,
"start_line": 57
} |
Prims.GTot | val includes (#a: typ) (x y: buffer a) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y | val includes (#a: typ) (x y: buffer a) : GTot Type0
let includes (#a: typ) (x y: buffer a) : GTot Type0 = | false | null | false | P.buffer_includes x y | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.buffer_includes"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a) | false | false | FStar.BufferNG.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 includes (#a: typ) (x y: buffer a) : GTot Type0 | [] | FStar.BufferNG.includes | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.BufferNG.buffer a -> y: FStar.BufferNG.buffer a -> Prims.GTot Type0 | {
"end_col": 23,
"end_line": 84,
"start_col": 2,
"start_line": 84
} |
Prims.GTot | val live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b | val live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 = | false | null | false | P.buffer_readable h b | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"FStar.Monotonic.HyperStack.mem",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.buffer_readable"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold | false | false | FStar.BufferNG.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 live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 | [] | FStar.BufferNG.live | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | h: FStar.Monotonic.HyperStack.mem -> b: FStar.BufferNG.buffer a -> Prims.GTot Type0 | {
"end_col": 23,
"end_line": 53,
"start_col": 2,
"start_line": 53
} |
Prims.GTot | val q (#a: typ) (len: nat) (buf: buffer a) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len) | val q (#a: typ) (len: nat) (buf: buffer a) : GTot Type0
let q (#a: typ) (len: nat) (buf: buffer a) : GTot Type0 = | false | null | false | normalize (length buf == len) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"Prims.nat",
"FStar.BufferNG.buffer",
"FStar.Pervasives.normalize",
"Prims.eq2",
"FStar.BufferNG.length"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32) | false | false | FStar.BufferNG.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 q (#a: typ) (len: nat) (buf: buffer a) : GTot Type0 | [] | FStar.BufferNG.q | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | len: Prims.nat -> buf: FStar.BufferNG.buffer a -> Prims.GTot Type0 | {
"end_col": 31,
"end_line": 165,
"start_col": 2,
"start_line": 165
} |
Prims.Tot | val buffer (t: typ) : Tot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 buffer
(t: typ)
: Tot Type0
= P.buffer t | val buffer (t: typ) : Tot Type0
let buffer (t: typ) : Tot Type0 = | false | null | false | P.buffer t | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"total"
] | [
"FStar.BufferNG.typ",
"FStar.Pointer.Base.buffer"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ) | false | true | FStar.BufferNG.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 buffer (t: typ) : Tot Type0 | [] | FStar.BufferNG.buffer | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | t: FStar.BufferNG.typ -> Type0 | {
"end_col": 12,
"end_line": 49,
"start_col": 2,
"start_line": 49
} |
Prims.GTot | val as_addr (#a: typ) (b: buffer a) : GTot nat | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b | val as_addr (#a: typ) (b: buffer a) : GTot nat
let as_addr (#a: typ) (b: buffer a) : GTot nat = | false | null | false | P.buffer_as_addr b | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.buffer_as_addr",
"Prims.nat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold | false | false | FStar.BufferNG.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 as_addr (#a: typ) (b: buffer a) : GTot nat | [] | FStar.BufferNG.as_addr | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> Prims.GTot Prims.nat | {
"end_col": 20,
"end_line": 65,
"start_col": 2,
"start_line": 65
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 typ = (t: P.typ { supported t } ) | let typ = | false | null | false | (t: P.typ{supported t}) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"total"
] | [
"FStar.Pointer.Base.typ",
"Prims.b2t",
"FStar.BufferNG.supported"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l' | false | true | FStar.BufferNG.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 typ : Type0 | [] | FStar.BufferNG.typ | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Type0 | {
"end_col": 37,
"end_line": 43,
"start_col": 10,
"start_line": 43
} |
|
Prims.GTot | val p (#a: typ) (init: list (P.type_of_typ a)) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32) | val p (#a: typ) (init: list (P.type_of_typ a)) : GTot Type0
let p (#a: typ) (init: list (P.type_of_typ a)) : GTot Type0 = | false | null | false | normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"Prims.list",
"FStar.Pointer.Base.type_of_typ",
"Prims.l_and",
"FStar.Pervasives.normalize",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.List.Tot.Base.length",
"FStar.UInt.max_int"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content | false | false | FStar.BufferNG.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 p (#a: typ) (init: list (P.type_of_typ a)) : GTot Type0 | [] | FStar.BufferNG.p | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | init: Prims.list (FStar.Pointer.Base.type_of_typ a) -> Prims.GTot Type0 | {
"end_col": 58,
"end_line": 162,
"start_col": 2,
"start_line": 161
} |
FStar.Pervasives.Lemma | val includes_trans (#a: _) (x y z: buffer a)
: Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z | val includes_trans (#a: _) (x y z: buffer a)
: Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z))
let includes_trans #a (x: buffer a) (y: buffer a) (z: buffer a)
: Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) = | false | null | true | P.buffer_includes_trans x y z | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"lemma"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.buffer_includes_trans",
"Prims.unit",
"Prims.l_and",
"FStar.BufferNG.includes",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z)) | false | false | FStar.BufferNG.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 includes_trans (#a: _) (x y z: buffer a)
: Lemma (requires (x `includes` y /\ y `includes` z)) (ensures (x `includes` z)) | [] | FStar.BufferNG.includes_trans | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.BufferNG.buffer a -> y: FStar.BufferNG.buffer a -> z: FStar.BufferNG.buffer a
-> FStar.Pervasives.Lemma (requires FStar.BufferNG.includes x y /\ FStar.BufferNG.includes y z)
(ensures FStar.BufferNG.includes x z) | {
"end_col": 31,
"end_line": 105,
"start_col": 2,
"start_line": 105
} |
Prims.GTot | val equal (#a: typ) (h: HS.mem) (b: buffer a) (h': HS.mem) (b': buffer a) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b' | val equal (#a: typ) (h: HS.mem) (b: buffer a) (h': HS.mem) (b': buffer a) : GTot Type0
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h': HS.mem) (b': buffer a) : GTot Type0 = | false | null | false | as_seq h b == as_seq h' b' | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"FStar.Monotonic.HyperStack.mem",
"FStar.BufferNG.buffer",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.Pointer.Base.type_of_typ",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"FStar.BufferNG.length",
"FStar.BufferNG.as_seq"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val equal (#a: typ) (h: HS.mem) (b: buffer a) (h': HS.mem) (b': buffer a) : GTot Type0 | [] | FStar.BufferNG.equal | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
h: FStar.Monotonic.HyperStack.mem ->
b: FStar.BufferNG.buffer a ->
h': FStar.Monotonic.HyperStack.mem ->
b': FStar.BufferNG.buffer a
-> Prims.GTot Type0 | {
"end_col": 28,
"end_line": 77,
"start_col": 2,
"start_line": 77
} |
Prims.GTot | val as_seq (#a: typ) (h: HS.mem) (b: buffer a)
: GTot (s: Seq.seq (P.type_of_typ a) {Seq.length s == length b}) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b | val as_seq (#a: typ) (h: HS.mem) (b: buffer a)
: GTot (s: Seq.seq (P.type_of_typ a) {Seq.length s == length b})
let as_seq (#a: typ) (h: HS.mem) (b: buffer a)
: GTot (s: Seq.seq (P.type_of_typ a) {Seq.length s == length b}) = | false | null | false | P.buffer_as_seq h b | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"FStar.Monotonic.HyperStack.mem",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.buffer_as_seq",
"FStar.Seq.Base.seq",
"FStar.Pointer.Base.type_of_typ",
"Prims.eq2",
"Prims.nat",
"FStar.Seq.Base.length",
"FStar.BufferNG.length"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold | false | false | FStar.BufferNG.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 as_seq (#a: typ) (h: HS.mem) (b: buffer a)
: GTot (s: Seq.seq (P.type_of_typ a) {Seq.length s == length b}) | [] | FStar.BufferNG.as_seq | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | h: FStar.Monotonic.HyperStack.mem -> b: FStar.BufferNG.buffer a
-> Prims.GTot
(s:
FStar.Seq.Base.seq (FStar.Pointer.Base.type_of_typ a)
{FStar.Seq.Base.length s == FStar.BufferNG.length b}) | {
"end_col": 21,
"end_line": 73,
"start_col": 2,
"start_line": 73
} |
FStar.Pervasives.Lemma | val lemma_disjoint_sub (#a #a': _) (x subx: buffer a) (y: buffer a')
: Lemma (requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)] | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y) | val lemma_disjoint_sub (#a #a': _) (x subx: buffer a) (y: buffer a')
: Lemma (requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
let lemma_disjoint_sub #a #a' (x: buffer a) (subx: buffer a) (y: buffer a')
: Lemma (requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)] = | false | null | true | P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"lemma"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.loc_disjoint_includes",
"FStar.Pointer.Base.loc_buffer",
"Prims.unit",
"FStar.Pointer.Base.buffer_includes_loc_includes",
"Prims.l_and",
"FStar.BufferNG.includes",
"FStar.BufferNG.disjoint",
"Prims.squash",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y)) | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_disjoint_sub (#a #a': _) (x subx: buffer a) (y: buffer a')
: Lemma (requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)] | [] | FStar.BufferNG.lemma_disjoint_sub | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.BufferNG.buffer a -> subx: FStar.BufferNG.buffer a -> y: FStar.BufferNG.buffer a'
-> FStar.Pervasives.Lemma (requires FStar.BufferNG.includes x subx /\ FStar.BufferNG.disjoint x y)
(ensures FStar.BufferNG.disjoint subx y)
[SMTPat (FStar.BufferNG.disjoint subx y); SMTPat (FStar.BufferNG.includes x subx)] | {
"end_col": 98,
"end_line": 123,
"start_col": 4,
"start_line": 122
} |
Prims.GTot | val length (#a: typ) (b: buffer a) : GTot nat | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b) | val length (#a: typ) (b: buffer a) : GTot nat
let length (#a: typ) (b: buffer a) : GTot nat = | false | null | false | UInt32.v (P.buffer_length b) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"sometrivial"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.v",
"FStar.Pointer.Base.buffer_length",
"Prims.nat"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val length (#a: typ) (b: buffer a) : GTot nat | [] | FStar.BufferNG.length | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> Prims.GTot Prims.nat | {
"end_col": 30,
"end_line": 61,
"start_col": 2,
"start_line": 61
} |
FStar.HyperStack.ST.Stack | val offset (#a: typ) (b: buffer a) (i: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 -> live h0 b /\ UInt32.v i <= length b))
(ensures (fun h0 b' h1 -> h1 == h0 /\ UInt32.v i <= length b /\ b' == goffset b i)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 offset
(#a:typ)
(b:buffer a)
(i:UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 ->
live h0 b /\
UInt32.v i <= length b
))
(ensures (fun h0 b' h1 ->
h1 == h0 /\
UInt32.v i <= length b /\
b' == goffset b i
))
= P.offset_buffer b i | val offset (#a: typ) (b: buffer a) (i: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 -> live h0 b /\ UInt32.v i <= length b))
(ensures (fun h0 b' h1 -> h1 == h0 /\ UInt32.v i <= length b /\ b' == goffset b i))
let offset (#a: typ) (b: buffer a) (i: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 -> live h0 b /\ UInt32.v i <= length b))
(ensures (fun h0 b' h1 -> h1 == h0 /\ UInt32.v i <= length b /\ b' == goffset b i)) = | true | null | false | P.offset_buffer b i | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Pointer.Base.offset_buffer",
"FStar.Pointer.Base.buffer",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"FStar.BufferNG.live",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"FStar.BufferNG.length",
"Prims.eq2",
"FStar.BufferNG.goffset"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len
let sub_sub
(#a: typ)
(b: buffer a)
(i1: UInt32.t)
(len1: UInt32.t)
(i2: UInt32.t)
(len2: UInt32.t)
: Lemma
(requires (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1
))
(ensures (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\
gsub (gsub b i1 len1) i2 len2 == gsub b (UInt32.add i1 i2) len2
))
= ()
let sub_zero_length
(#a: typ)
(b: buffer a)
: Lemma
(ensures (gsub b (UInt32.uint_to_t 0) (UInt32.uint_to_t (length b)) == b))
= ()
let lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))]
]]
= Seq.lemma_eq_intro (as_seq h (gsub b i len)) (Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))
(* Same here *)
let goffset
(#a: typ)
(b: buffer a)
(i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures (fun b' ->
UInt32.v i <= length b /\
b' == gsub b i (UInt32.sub (P.buffer_length b) i)
))
= P.gsub_buffer b i (UInt32.sub (P.buffer_length b) i)
let offset
(#a:typ)
(b:buffer a)
(i:UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 ->
live h0 b /\
UInt32.v i <= length b
))
(ensures (fun h0 b' h1 ->
h1 == h0 /\
UInt32.v i <= length b /\
b' == goffset b i | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 offset (#a: typ) (b: buffer a) (i: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 -> live h0 b /\ UInt32.v i <= length b))
(ensures (fun h0 b' h1 -> h1 == h0 /\ UInt32.v i <= length b /\ b' == goffset b i)) | [] | FStar.BufferNG.offset | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> i: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack (FStar.BufferNG.buffer a) | {
"end_col": 21,
"end_line": 370,
"start_col": 2,
"start_line": 370
} |
Prims.Ghost | val gsub (#a: typ) (b: buffer a) (i len: UInt32.t)
: Ghost (buffer a) (requires (UInt32.v i + UInt32.v len <= length b)) (ensures (fun _ -> True)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len | val gsub (#a: typ) (b: buffer a) (i len: UInt32.t)
: Ghost (buffer a) (requires (UInt32.v i + UInt32.v len <= length b)) (ensures (fun _ -> True))
let gsub (#a: typ) (b: buffer a) (i len: UInt32.t)
: Ghost (buffer a) (requires (UInt32.v i + UInt32.v len <= length b)) (ensures (fun _ -> True)) = | false | null | false | P.gsub_buffer b i len | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Pointer.Base.gsub_buffer",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.UInt32.v",
"FStar.BufferNG.length",
"Prims.l_True"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b)) | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 gsub (#a: typ) (b: buffer a) (i len: UInt32.t)
: Ghost (buffer a) (requires (UInt32.v i + UInt32.v len <= length b)) (ensures (fun _ -> True)) | [] | FStar.BufferNG.gsub | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> i: FStar.UInt32.t -> len: FStar.UInt32.t
-> Prims.Ghost (FStar.BufferNG.buffer a) | {
"end_col": 23,
"end_line": 275,
"start_col": 2,
"start_line": 275
} |
FStar.Pervasives.Lemma | val includes_live (#a: typ) (h: HS.mem) (x y: buffer a)
: Lemma (requires (x `includes` y /\ live h x)) (ensures (live h y)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y | val includes_live (#a: typ) (h: HS.mem) (x y: buffer a)
: Lemma (requires (x `includes` y /\ live h x)) (ensures (live h y))
let includes_live (#a: typ) (h: HS.mem) (x y: buffer a)
: Lemma (requires (x `includes` y /\ live h x)) (ensures (live h y)) = | false | null | true | P.buffer_includes_elim x y | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"lemma"
] | [
"FStar.BufferNG.typ",
"FStar.Monotonic.HyperStack.mem",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.buffer_includes_elim",
"Prims.unit",
"Prims.l_and",
"FStar.BufferNG.includes",
"FStar.BufferNG.live",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x)) | false | false | FStar.BufferNG.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 includes_live (#a: typ) (h: HS.mem) (x y: buffer a)
: Lemma (requires (x `includes` y /\ live h x)) (ensures (live h y)) | [] | FStar.BufferNG.includes_live | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | h: FStar.Monotonic.HyperStack.mem -> x: FStar.BufferNG.buffer a -> y: FStar.BufferNG.buffer a
-> FStar.Pervasives.Lemma (requires FStar.BufferNG.includes x y /\ FStar.BufferNG.live h x)
(ensures FStar.BufferNG.live h y) | {
"end_col": 28,
"end_line": 93,
"start_col": 2,
"start_line": 93
} |
FStar.HyperStack.ST.StackInline | val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content | val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len = | true | null | false | let len:P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.Pointer.Base.type_of_typ",
"FStar.UInt32.t",
"FStar.Pointer.Base.buffer_of_array_pointer",
"FStar.Pointer.Base.buffer",
"FStar.Pointer.Base.pointer",
"FStar.Pointer.Base.TArray",
"FStar.Pointer.Base.screate",
"FStar.Pervasives.Native.Some",
"FStar.Seq.Base.create",
"FStar.UInt32.v",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.array_length_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
)) | [] | FStar.BufferNG.create | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | init: FStar.Pointer.Base.type_of_typ a -> len: FStar.UInt32.t
-> FStar.HyperStack.ST.StackInline (FStar.BufferNG.buffer a) | {
"end_col": 35,
"end_line": 158,
"start_col": 24,
"start_line": 155
} |
FStar.HyperStack.ST.Stack | val sub (#a: typ) (b: buffer a) (i len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h -> live h b /\ UInt32.v i + UInt32.v len <= length b))
(ensures
(fun h0 b' h1 ->
live h0 b /\ UInt32.v i + UInt32.v len <= length b /\ h1 == h0 /\ b' == gsub b i len /\
b `includes` b')) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len | val sub (#a: typ) (b: buffer a) (i len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h -> live h b /\ UInt32.v i + UInt32.v len <= length b))
(ensures
(fun h0 b' h1 ->
live h0 b /\ UInt32.v i + UInt32.v len <= length b /\ h1 == h0 /\ b' == gsub b i len /\
b `includes` b'))
let sub (#a: typ) (b: buffer a) (i len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h -> live h b /\ UInt32.v i + UInt32.v len <= length b))
(ensures
(fun h0 b' h1 ->
live h0 b /\ UInt32.v i + UInt32.v len <= length b /\ h1 == h0 /\ b' == gsub b i len /\
b `includes` b')) = | true | null | false | P.sub_buffer b i len | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Pointer.Base.sub_buffer",
"FStar.Pointer.Base.buffer",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"FStar.BufferNG.live",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.UInt32.v",
"FStar.BufferNG.length",
"Prims.eq2",
"FStar.BufferNG.gsub",
"FStar.BufferNG.includes"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b' | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub (#a: typ) (b: buffer a) (i len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h -> live h b /\ UInt32.v i + UInt32.v len <= length b))
(ensures
(fun h0 b' h1 ->
live h0 b /\ UInt32.v i + UInt32.v len <= length b /\ h1 == h0 /\ b' == gsub b i len /\
b `includes` b')) | [] | FStar.BufferNG.sub | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> i: FStar.UInt32.t -> len: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack (FStar.BufferNG.buffer a) | {
"end_col": 22,
"end_line": 294,
"start_col": 2,
"start_line": 294
} |
FStar.Pervasives.Lemma | val live_slice_middle
(#t: typ)
(b: buffer t)
(i: UInt32.t)
(len: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b 0ul i) /\
live h (gsub b i len) /\ (
let off = UInt32.add i len in
live h (gsub b off (UInt32.sub (P.buffer_length b) off))
)))
(ensures (live h b))
[SMTPat (live h (gsub b i len))] | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 live_slice_middle #t b i len h =
P.buffer_readable_gsub_merge b i len h | val live_slice_middle
(#t: typ)
(b: buffer t)
(i: UInt32.t)
(len: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b 0ul i) /\
live h (gsub b i len) /\ (
let off = UInt32.add i len in
live h (gsub b off (UInt32.sub (P.buffer_length b) off))
)))
(ensures (live h b))
[SMTPat (live h (gsub b i len))]
let live_slice_middle #t b i len h = | false | null | true | P.buffer_readable_gsub_merge b i len h | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"lemma"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"FStar.Pointer.Derived1.buffer_readable_gsub_merge",
"Prims.unit"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len
let sub_sub
(#a: typ)
(b: buffer a)
(i1: UInt32.t)
(len1: UInt32.t)
(i2: UInt32.t)
(len2: UInt32.t)
: Lemma
(requires (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1
))
(ensures (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\
gsub (gsub b i1 len1) i2 len2 == gsub b (UInt32.add i1 i2) len2
))
= ()
let sub_zero_length
(#a: typ)
(b: buffer a)
: Lemma
(ensures (gsub b (UInt32.uint_to_t 0) (UInt32.uint_to_t (length b)) == b))
= ()
let lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))]
]]
= Seq.lemma_eq_intro (as_seq h (gsub b i len)) (Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))
(* Same here *)
let goffset
(#a: typ)
(b: buffer a)
(i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures (fun b' ->
UInt32.v i <= length b /\
b' == gsub b i (UInt32.sub (P.buffer_length b) i)
))
= P.gsub_buffer b i (UInt32.sub (P.buffer_length b) i)
let offset
(#a:typ)
(b:buffer a)
(i:UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 ->
live h0 b /\
UInt32.v i <= length b
))
(ensures (fun h0 b' h1 ->
h1 == h0 /\
UInt32.v i <= length b /\
b' == goffset b i
))
= P.offset_buffer b i
let lemma_offset_spec
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i <= length b /\
live h b
))
(ensures (
UInt32.v i <= length b /\
as_seq h (goffset b i) == Seq.slice (as_seq h b) (UInt32.v i) (length b)
))
= ()
val eqb: #a:typ -> b1:buffer a -> b2:buffer a
-> len:UInt32.t
-> HST.ST bool
(requires (fun h ->
hasEq (P.type_of_typ a) /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
live h b1 /\
live h b2
))
(ensures (fun h0 z h1 ->
h1 == h0 /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
(z <==> equal h0 (gsub b1 0ul len) h0 (gsub b2 0ul len))
))
let eqb #a b1 b2 len =
P.buffer_contents_equal b1 b2 len
(* JP: if the [val] is not specified, there's an issue with these functions
* taking an extra unification parameter at extraction-time... *)
val op_Array_Access: #a:typ -> b:buffer a -> n:UInt32.t -> HST.Stack (P.type_of_typ a)
(requires (fun h -> UInt32.v n<length b /\ live h b))
(ensures (fun h0 z h1 -> h1 == h0 /\
UInt32.v n<length b /\
z == Seq.index (as_seq h0 b) (UInt32.v n)))
let op_Array_Access #a b n = index #a b n
val op_Array_Assignment: #a:typ -> b:buffer a -> n:UInt32.t -> z:P.type_of_typ a -> HST.Stack unit
(requires (fun h -> live h b /\ UInt32.v n < length b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ UInt32.v n < length b
/\ P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1
/\ as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z ))
let op_Array_Assignment #a b n z = upd #a b n z
val live_slice_middle
(#t: typ)
(b: buffer t)
(i: UInt32.t)
(len: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b 0ul i) /\
live h (gsub b i len) /\ (
let off = UInt32.add i len in
live h (gsub b off (UInt32.sub (P.buffer_length b) off))
)))
(ensures (live h b))
[SMTPat (live h (gsub b i len))] | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 live_slice_middle
(#t: typ)
(b: buffer t)
(i: UInt32.t)
(len: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b 0ul i) /\
live h (gsub b i len) /\ (
let off = UInt32.add i len in
live h (gsub b off (UInt32.sub (P.buffer_length b) off))
)))
(ensures (live h b))
[SMTPat (live h (gsub b i len))] | [] | FStar.BufferNG.live_slice_middle | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
b: FStar.BufferNG.buffer t ->
i: FStar.UInt32.t ->
len: FStar.UInt32.t ->
h: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
FStar.UInt32.v i + FStar.UInt32.v len <= FStar.BufferNG.length b /\
FStar.BufferNG.live h (FStar.BufferNG.gsub b 0ul i) /\
FStar.BufferNG.live h (FStar.BufferNG.gsub b i len) /\
(let off = FStar.UInt32.add i len in
FStar.BufferNG.live h
(FStar.BufferNG.gsub b off (FStar.UInt32.sub (FStar.Pointer.Base.buffer_length b) off)))
)
(ensures FStar.BufferNG.live h b)
[SMTPat (FStar.BufferNG.live h (FStar.BufferNG.gsub b i len))] | {
"end_col": 40,
"end_line": 442,
"start_col": 2,
"start_line": 442
} |
FStar.Pervasives.Lemma | val includes_as_seq (#a h1 h2: _) (x y: buffer a)
: Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y | val includes_as_seq (#a h1 h2: _) (x y: buffer a)
: Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y)) = | false | null | true | P.buffer_includes_elim x y | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"lemma"
] | [
"FStar.BufferNG.typ",
"FStar.Monotonic.HyperStack.mem",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.buffer_includes_elim",
"Prims.unit",
"Prims.l_and",
"FStar.BufferNG.includes",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.Pointer.Base.type_of_typ",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"FStar.BufferNG.length",
"FStar.BufferNG.as_seq",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x)) | false | false | FStar.BufferNG.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 includes_as_seq (#a h1 h2: _) (x y: buffer a)
: Lemma (requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y)) | [] | FStar.BufferNG.includes_as_seq | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
h1: FStar.Monotonic.HyperStack.mem ->
h2: FStar.Monotonic.HyperStack.mem ->
x: FStar.BufferNG.buffer a ->
y: FStar.BufferNG.buffer a
-> FStar.Pervasives.Lemma
(requires
FStar.BufferNG.includes x y /\ FStar.BufferNG.as_seq h1 x == FStar.BufferNG.as_seq h2 x)
(ensures FStar.BufferNG.as_seq h1 y == FStar.BufferNG.as_seq h2 y) | {
"end_col": 28,
"end_line": 99,
"start_col": 2,
"start_line": 99
} |
FStar.HyperStack.ST.Stack | val op_Array_Access: #a:typ -> b:buffer a -> n:UInt32.t -> HST.Stack (P.type_of_typ a)
(requires (fun h -> UInt32.v n<length b /\ live h b))
(ensures (fun h0 z h1 -> h1 == h0 /\
UInt32.v n<length b /\
z == Seq.index (as_seq h0 b) (UInt32.v n))) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 op_Array_Access #a b n = index #a b n | val op_Array_Access: #a:typ -> b:buffer a -> n:UInt32.t -> HST.Stack (P.type_of_typ a)
(requires (fun h -> UInt32.v n<length b /\ live h b))
(ensures (fun h0 z h1 -> h1 == h0 /\
UInt32.v n<length b /\
z == Seq.index (as_seq h0 b) (UInt32.v n)))
let op_Array_Access #a b n = | true | null | false | index #a b n | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.BufferNG.index",
"FStar.Pointer.Base.type_of_typ"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len
let sub_sub
(#a: typ)
(b: buffer a)
(i1: UInt32.t)
(len1: UInt32.t)
(i2: UInt32.t)
(len2: UInt32.t)
: Lemma
(requires (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1
))
(ensures (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\
gsub (gsub b i1 len1) i2 len2 == gsub b (UInt32.add i1 i2) len2
))
= ()
let sub_zero_length
(#a: typ)
(b: buffer a)
: Lemma
(ensures (gsub b (UInt32.uint_to_t 0) (UInt32.uint_to_t (length b)) == b))
= ()
let lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))]
]]
= Seq.lemma_eq_intro (as_seq h (gsub b i len)) (Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))
(* Same here *)
let goffset
(#a: typ)
(b: buffer a)
(i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures (fun b' ->
UInt32.v i <= length b /\
b' == gsub b i (UInt32.sub (P.buffer_length b) i)
))
= P.gsub_buffer b i (UInt32.sub (P.buffer_length b) i)
let offset
(#a:typ)
(b:buffer a)
(i:UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 ->
live h0 b /\
UInt32.v i <= length b
))
(ensures (fun h0 b' h1 ->
h1 == h0 /\
UInt32.v i <= length b /\
b' == goffset b i
))
= P.offset_buffer b i
let lemma_offset_spec
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i <= length b /\
live h b
))
(ensures (
UInt32.v i <= length b /\
as_seq h (goffset b i) == Seq.slice (as_seq h b) (UInt32.v i) (length b)
))
= ()
val eqb: #a:typ -> b1:buffer a -> b2:buffer a
-> len:UInt32.t
-> HST.ST bool
(requires (fun h ->
hasEq (P.type_of_typ a) /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
live h b1 /\
live h b2
))
(ensures (fun h0 z h1 ->
h1 == h0 /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
(z <==> equal h0 (gsub b1 0ul len) h0 (gsub b2 0ul len))
))
let eqb #a b1 b2 len =
P.buffer_contents_equal b1 b2 len
(* JP: if the [val] is not specified, there's an issue with these functions
* taking an extra unification parameter at extraction-time... *)
val op_Array_Access: #a:typ -> b:buffer a -> n:UInt32.t -> HST.Stack (P.type_of_typ a)
(requires (fun h -> UInt32.v n<length b /\ live h b))
(ensures (fun h0 z h1 -> h1 == h0 /\
UInt32.v n<length b /\ | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 op_Array_Access: #a:typ -> b:buffer a -> n:UInt32.t -> HST.Stack (P.type_of_typ a)
(requires (fun h -> UInt32.v n<length b /\ live h b))
(ensures (fun h0 z h1 -> h1 == h0 /\
UInt32.v n<length b /\
z == Seq.index (as_seq h0 b) (UInt32.v n))) | [] | FStar.BufferNG.op_Array_Access | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> n: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack (FStar.Pointer.Base.type_of_typ a) | {
"end_col": 41,
"end_line": 415,
"start_col": 29,
"start_line": 415
} |
FStar.HyperStack.ST.Stack | val op_Array_Assignment: #a:typ -> b:buffer a -> n:UInt32.t -> z:P.type_of_typ a -> HST.Stack unit
(requires (fun h -> live h b /\ UInt32.v n < length b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ UInt32.v n < length b
/\ P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1
/\ as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z )) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 op_Array_Assignment #a b n z = upd #a b n z | val op_Array_Assignment: #a:typ -> b:buffer a -> n:UInt32.t -> z:P.type_of_typ a -> HST.Stack unit
(requires (fun h -> live h b /\ UInt32.v n < length b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ UInt32.v n < length b
/\ P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1
/\ as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z ))
let op_Array_Assignment #a b n z = | true | null | false | upd #a b n z | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Pointer.Base.type_of_typ",
"FStar.BufferNG.upd",
"Prims.unit"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len
let sub_sub
(#a: typ)
(b: buffer a)
(i1: UInt32.t)
(len1: UInt32.t)
(i2: UInt32.t)
(len2: UInt32.t)
: Lemma
(requires (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1
))
(ensures (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\
gsub (gsub b i1 len1) i2 len2 == gsub b (UInt32.add i1 i2) len2
))
= ()
let sub_zero_length
(#a: typ)
(b: buffer a)
: Lemma
(ensures (gsub b (UInt32.uint_to_t 0) (UInt32.uint_to_t (length b)) == b))
= ()
let lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))]
]]
= Seq.lemma_eq_intro (as_seq h (gsub b i len)) (Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))
(* Same here *)
let goffset
(#a: typ)
(b: buffer a)
(i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures (fun b' ->
UInt32.v i <= length b /\
b' == gsub b i (UInt32.sub (P.buffer_length b) i)
))
= P.gsub_buffer b i (UInt32.sub (P.buffer_length b) i)
let offset
(#a:typ)
(b:buffer a)
(i:UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 ->
live h0 b /\
UInt32.v i <= length b
))
(ensures (fun h0 b' h1 ->
h1 == h0 /\
UInt32.v i <= length b /\
b' == goffset b i
))
= P.offset_buffer b i
let lemma_offset_spec
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i <= length b /\
live h b
))
(ensures (
UInt32.v i <= length b /\
as_seq h (goffset b i) == Seq.slice (as_seq h b) (UInt32.v i) (length b)
))
= ()
val eqb: #a:typ -> b1:buffer a -> b2:buffer a
-> len:UInt32.t
-> HST.ST bool
(requires (fun h ->
hasEq (P.type_of_typ a) /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
live h b1 /\
live h b2
))
(ensures (fun h0 z h1 ->
h1 == h0 /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
(z <==> equal h0 (gsub b1 0ul len) h0 (gsub b2 0ul len))
))
let eqb #a b1 b2 len =
P.buffer_contents_equal b1 b2 len
(* JP: if the [val] is not specified, there's an issue with these functions
* taking an extra unification parameter at extraction-time... *)
val op_Array_Access: #a:typ -> b:buffer a -> n:UInt32.t -> HST.Stack (P.type_of_typ a)
(requires (fun h -> UInt32.v n<length b /\ live h b))
(ensures (fun h0 z h1 -> h1 == h0 /\
UInt32.v n<length b /\
z == Seq.index (as_seq h0 b) (UInt32.v n)))
let op_Array_Access #a b n = index #a b n
val op_Array_Assignment: #a:typ -> b:buffer a -> n:UInt32.t -> z:P.type_of_typ a -> HST.Stack unit
(requires (fun h -> live h b /\ UInt32.v n < length b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ UInt32.v n < length b
/\ P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 op_Array_Assignment: #a:typ -> b:buffer a -> n:UInt32.t -> z:P.type_of_typ a -> HST.Stack unit
(requires (fun h -> live h b /\ UInt32.v n < length b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ UInt32.v n < length b
/\ P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1
/\ as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z )) | [] | FStar.BufferNG.op_Array_Assignment | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> n: FStar.UInt32.t -> z: FStar.Pointer.Base.type_of_typ a
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 47,
"end_line": 422,
"start_col": 35,
"start_line": 422
} |
FStar.HyperStack.ST.ST | val eqb: #a:typ -> b1:buffer a -> b2:buffer a
-> len:UInt32.t
-> HST.ST bool
(requires (fun h ->
hasEq (P.type_of_typ a) /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
live h b1 /\
live h b2
))
(ensures (fun h0 z h1 ->
h1 == h0 /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
(z <==> equal h0 (gsub b1 0ul len) h0 (gsub b2 0ul len))
)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 eqb #a b1 b2 len =
P.buffer_contents_equal b1 b2 len | val eqb: #a:typ -> b1:buffer a -> b2:buffer a
-> len:UInt32.t
-> HST.ST bool
(requires (fun h ->
hasEq (P.type_of_typ a) /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
live h b1 /\
live h b2
))
(ensures (fun h0 z h1 ->
h1 == h0 /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
(z <==> equal h0 (gsub b1 0ul len) h0 (gsub b2 0ul len))
))
let eqb #a b1 b2 len = | true | null | false | P.buffer_contents_equal b1 b2 len | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Pointer.Derived1.buffer_contents_equal",
"Prims.bool"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len
let sub_sub
(#a: typ)
(b: buffer a)
(i1: UInt32.t)
(len1: UInt32.t)
(i2: UInt32.t)
(len2: UInt32.t)
: Lemma
(requires (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1
))
(ensures (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\
gsub (gsub b i1 len1) i2 len2 == gsub b (UInt32.add i1 i2) len2
))
= ()
let sub_zero_length
(#a: typ)
(b: buffer a)
: Lemma
(ensures (gsub b (UInt32.uint_to_t 0) (UInt32.uint_to_t (length b)) == b))
= ()
let lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))]
]]
= Seq.lemma_eq_intro (as_seq h (gsub b i len)) (Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))
(* Same here *)
let goffset
(#a: typ)
(b: buffer a)
(i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures (fun b' ->
UInt32.v i <= length b /\
b' == gsub b i (UInt32.sub (P.buffer_length b) i)
))
= P.gsub_buffer b i (UInt32.sub (P.buffer_length b) i)
let offset
(#a:typ)
(b:buffer a)
(i:UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 ->
live h0 b /\
UInt32.v i <= length b
))
(ensures (fun h0 b' h1 ->
h1 == h0 /\
UInt32.v i <= length b /\
b' == goffset b i
))
= P.offset_buffer b i
let lemma_offset_spec
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i <= length b /\
live h b
))
(ensures (
UInt32.v i <= length b /\
as_seq h (goffset b i) == Seq.slice (as_seq h b) (UInt32.v i) (length b)
))
= ()
val eqb: #a:typ -> b1:buffer a -> b2:buffer a
-> len:UInt32.t
-> HST.ST bool
(requires (fun h ->
hasEq (P.type_of_typ a) /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
live h b1 /\
live h b2
))
(ensures (fun h0 z h1 ->
h1 == h0 /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
(z <==> equal h0 (gsub b1 0ul len) h0 (gsub b2 0ul len))
)) | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 eqb: #a:typ -> b1:buffer a -> b2:buffer a
-> len:UInt32.t
-> HST.ST bool
(requires (fun h ->
hasEq (P.type_of_typ a) /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
live h b1 /\
live h b2
))
(ensures (fun h0 z h1 ->
h1 == h0 /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
(z <==> equal h0 (gsub b1 0ul len) h0 (gsub b2 0ul len))
)) | [] | FStar.BufferNG.eqb | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b1: FStar.BufferNG.buffer a -> b2: FStar.BufferNG.buffer a -> len: FStar.UInt32.t
-> FStar.HyperStack.ST.ST Prims.bool | {
"end_col": 35,
"end_line": 406,
"start_col": 2,
"start_line": 406
} |
FStar.HyperStack.ST.Stack | val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 index #a b n =
P.read_buffer b n | val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n = | true | null | false | P.read_buffer b n | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Pointer.Base.read_buffer",
"FStar.Pointer.Base.type_of_typ"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
)) | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
)) | [] | FStar.BufferNG.index | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> n: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack (FStar.Pointer.Base.type_of_typ a) | {
"end_col": 19,
"end_line": 236,
"start_col": 2,
"start_line": 236
} |
Prims.Ghost | val goffset (#a: typ) (b: buffer a) (i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures
(fun b' -> UInt32.v i <= length b /\ b' == gsub b i (UInt32.sub (P.buffer_length b) i))) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 goffset
(#a: typ)
(b: buffer a)
(i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures (fun b' ->
UInt32.v i <= length b /\
b' == gsub b i (UInt32.sub (P.buffer_length b) i)
))
= P.gsub_buffer b i (UInt32.sub (P.buffer_length b) i) | val goffset (#a: typ) (b: buffer a) (i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures
(fun b' -> UInt32.v i <= length b /\ b' == gsub b i (UInt32.sub (P.buffer_length b) i)))
let goffset (#a: typ) (b: buffer a) (i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures
(fun b' -> UInt32.v i <= length b /\ b' == gsub b i (UInt32.sub (P.buffer_length b) i))) = | false | null | false | P.gsub_buffer b i (UInt32.sub (P.buffer_length b) i) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Pointer.Base.gsub_buffer",
"FStar.UInt32.sub",
"FStar.Pointer.Base.buffer_length",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"FStar.BufferNG.length",
"Prims.l_and",
"Prims.eq2",
"FStar.BufferNG.gsub"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len
let sub_sub
(#a: typ)
(b: buffer a)
(i1: UInt32.t)
(len1: UInt32.t)
(i2: UInt32.t)
(len2: UInt32.t)
: Lemma
(requires (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1
))
(ensures (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\
gsub (gsub b i1 len1) i2 len2 == gsub b (UInt32.add i1 i2) len2
))
= ()
let sub_zero_length
(#a: typ)
(b: buffer a)
: Lemma
(ensures (gsub b (UInt32.uint_to_t 0) (UInt32.uint_to_t (length b)) == b))
= ()
let lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))]
]]
= Seq.lemma_eq_intro (as_seq h (gsub b i len)) (Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))
(* Same here *)
let goffset
(#a: typ)
(b: buffer a)
(i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures (fun b' ->
UInt32.v i <= length b /\
b' == gsub b i (UInt32.sub (P.buffer_length b) i) | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 goffset (#a: typ) (b: buffer a) (i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures
(fun b' -> UInt32.v i <= length b /\ b' == gsub b i (UInt32.sub (P.buffer_length b) i))) | [] | FStar.BufferNG.goffset | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> i: FStar.UInt32.t -> Prims.Ghost (FStar.BufferNG.buffer a) | {
"end_col": 54,
"end_line": 354,
"start_col": 2,
"start_line": 354
} |
FStar.HyperStack.ST.ST | val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content | val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len = | true | null | false | let len:P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.Monotonic.HyperHeap.rid",
"FStar.Pointer.Base.type_of_typ",
"FStar.UInt32.t",
"FStar.Pointer.Base.buffer_of_array_pointer",
"FStar.Pointer.Base.buffer",
"FStar.Pointer.Base.pointer",
"FStar.Pointer.Base.TArray",
"FStar.Pointer.Base.ecreate",
"FStar.Pervasives.Native.Some",
"FStar.Seq.Base.create",
"FStar.UInt32.v",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.array_length_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
)) | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
)) | [] | FStar.BufferNG.rcreate | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | r: FStar.Monotonic.HyperHeap.rid -> init: FStar.Pointer.Base.type_of_typ a -> len: FStar.UInt32.t
-> FStar.HyperStack.ST.ST (FStar.BufferNG.buffer a) | {
"end_col": 35,
"end_line": 218,
"start_col": 27,
"start_line": 215
} |
FStar.HyperStack.ST.StackInline | val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content | val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
let createL #a init = | true | null | false | let len:P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"Prims.list",
"FStar.Pointer.Base.type_of_typ",
"FStar.Pointer.Base.buffer_of_array_pointer",
"FStar.Pointer.Base.buffer",
"FStar.Pointer.Base.pointer",
"FStar.Pointer.Base.TArray",
"FStar.Pointer.Base.screate",
"FStar.Pervasives.Native.Some",
"FStar.BufferNG.buffer",
"FStar.Seq.Base.seq",
"Prims.b2t",
"Prims.op_Equality",
"Prims.nat",
"FStar.List.Tot.Base.length",
"FStar.Seq.Base.length",
"FStar.Seq.Properties.seq_of_list",
"FStar.Pointer.Base.array_length_t",
"FStar.UInt32.uint_to_t"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 1,
"max_fuel": 1,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
)) | [] | FStar.BufferNG.createL | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | init: Prims.list (FStar.Pointer.Base.type_of_typ a)
-> FStar.HyperStack.ST.StackInline (FStar.BufferNG.buffer a) | {
"end_col": 35,
"end_line": 191,
"start_col": 21,
"start_line": 187
} |
FStar.Pervasives.Lemma | val lemma_sub_spec (#a: typ) (b: buffer a) (i len: UInt32.t) (h: HS.mem)
: Lemma (requires (UInt32.v i + UInt32.v len <= length b /\ live h b))
(ensures
(UInt32.v i + UInt32.v len <= length b /\ live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [[SMTPat (gsub b i len); SMTPat (live h b)]; [SMTPat (live h (gsub b i len))]]] | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))]
]]
= Seq.lemma_eq_intro (as_seq h (gsub b i len)) (Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)) | val lemma_sub_spec (#a: typ) (b: buffer a) (i len: UInt32.t) (h: HS.mem)
: Lemma (requires (UInt32.v i + UInt32.v len <= length b /\ live h b))
(ensures
(UInt32.v i + UInt32.v len <= length b /\ live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [[SMTPat (gsub b i len); SMTPat (live h b)]; [SMTPat (live h (gsub b i len))]]]
let lemma_sub_spec (#a: typ) (b: buffer a) (i len: UInt32.t) (h: HS.mem)
: Lemma (requires (UInt32.v i + UInt32.v len <= length b /\ live h b))
(ensures
(UInt32.v i + UInt32.v len <= length b /\ live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [[SMTPat (gsub b i len); SMTPat (live h b)]; [SMTPat (live h (gsub b i len))]]] = | false | null | true | Seq.lemma_eq_intro (as_seq h (gsub b i len))
(Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [
"lemma"
] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Pointer.Base.type_of_typ",
"FStar.BufferNG.as_seq",
"FStar.BufferNG.gsub",
"FStar.Seq.Base.slice",
"FStar.UInt32.v",
"Prims.op_Addition",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.BufferNG.length",
"FStar.BufferNG.live",
"Prims.squash",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.Cons",
"FStar.Pervasives.pattern",
"FStar.Pervasives.smt_pat_or",
"Prims.list",
"FStar.Pervasives.smt_pat",
"Prims.Nil"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len
let sub_sub
(#a: typ)
(b: buffer a)
(i1: UInt32.t)
(len1: UInt32.t)
(i2: UInt32.t)
(len2: UInt32.t)
: Lemma
(requires (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1
))
(ensures (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\
gsub (gsub b i1 len1) i2 len2 == gsub b (UInt32.add i1 i2) len2
))
= ()
let sub_zero_length
(#a: typ)
(b: buffer a)
: Lemma
(ensures (gsub b (UInt32.uint_to_t 0) (UInt32.uint_to_t (length b)) == b))
= ()
let lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))] | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_sub_spec (#a: typ) (b: buffer a) (i len: UInt32.t) (h: HS.mem)
: Lemma (requires (UInt32.v i + UInt32.v len <= length b /\ live h b))
(ensures
(UInt32.v i + UInt32.v len <= length b /\ live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [[SMTPat (gsub b i len); SMTPat (live h b)]; [SMTPat (live h (gsub b i len))]]] | [] | FStar.BufferNG.lemma_sub_spec | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
b: FStar.BufferNG.buffer a ->
i: FStar.UInt32.t ->
len: FStar.UInt32.t ->
h: FStar.Monotonic.HyperStack.mem
-> FStar.Pervasives.Lemma
(requires
FStar.UInt32.v i + FStar.UInt32.v len <= FStar.BufferNG.length b /\ FStar.BufferNG.live h b)
(ensures
FStar.UInt32.v i + FStar.UInt32.v len <= FStar.BufferNG.length b /\
FStar.BufferNG.live h (FStar.BufferNG.gsub b i len) /\
FStar.BufferNG.as_seq h (FStar.BufferNG.gsub b i len) ==
FStar.Seq.Base.slice (FStar.BufferNG.as_seq h b)
(FStar.UInt32.v i)
(FStar.UInt32.v i + FStar.UInt32.v len))
[
SMTPatOr [
[SMTPat (FStar.BufferNG.gsub b i len); SMTPat (FStar.BufferNG.live h b)];
[SMTPat (FStar.BufferNG.live h (FStar.BufferNG.gsub b i len))]
]
] | {
"end_col": 114,
"end_line": 340,
"start_col": 4,
"start_line": 340
} |
FStar.HyperStack.ST.Stack | val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
)) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z)) | val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z = | true | null | false | let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z)) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.Pointer.Base.type_of_typ",
"Prims._assert",
"FStar.Seq.Base.equal",
"FStar.BufferNG.as_seq",
"FStar.Seq.Base.upd",
"FStar.UInt32.v",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"FStar.Pointer.Base.write_buffer"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
)) | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
)) | [] | FStar.BufferNG.upd | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | b: FStar.BufferNG.buffer a -> n: FStar.UInt32.t -> z: FStar.Pointer.Base.type_of_typ a
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 73,
"end_line": 259,
"start_col": 18,
"start_line": 255
} |
FStar.HyperStack.ST.Stack | val fill: #t:typ
-> b:buffer t
-> z: P.type_of_typ t
-> len:UInt32.t{UInt32.v len <= length b}
-> HST.Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\
P.modifies (P.loc_buffer (gsub b 0ul len)) h0 h1
/\ Seq.slice (as_seq h1 b) 0 (UInt32.v len) == Seq.create (UInt32.v len) z
/\ Seq.slice (as_seq h1 b) (UInt32.v len) (length b) ==
Seq.slice (as_seq h0 b) (UInt32.v len) (length b) )) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 fill #t b z len =
let h0 = HST.get () in
P.fill_buffer b 0ul len z;
let h1 = HST.get () in
assert (as_seq h1 (gsub b 0ul len) == Seq.slice (as_seq h1 b) 0 (UInt32.v len));
assert (let g = gsub b len (UInt32.sub (P.buffer_length b) len) in as_seq h1 g == as_seq h0 g) | val fill: #t:typ
-> b:buffer t
-> z: P.type_of_typ t
-> len:UInt32.t{UInt32.v len <= length b}
-> HST.Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\
P.modifies (P.loc_buffer (gsub b 0ul len)) h0 h1
/\ Seq.slice (as_seq h1 b) 0 (UInt32.v len) == Seq.create (UInt32.v len) z
/\ Seq.slice (as_seq h1 b) (UInt32.v len) (length b) ==
Seq.slice (as_seq h0 b) (UInt32.v len) (length b) ))
let fill #t b z len = | true | null | false | let h0 = HST.get () in
P.fill_buffer b 0ul len z;
let h1 = HST.get () in
assert (as_seq h1 (gsub b 0ul len) == Seq.slice (as_seq h1 b) 0 (UInt32.v len));
assert (let g = gsub b len (UInt32.sub (P.buffer_length b) len) in
as_seq h1 g == as_seq h0 g) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.Pointer.Base.type_of_typ",
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"FStar.BufferNG.length",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"FStar.BufferNG.as_seq",
"FStar.Pointer.Base.buffer",
"FStar.BufferNG.gsub",
"FStar.UInt32.sub",
"FStar.Pointer.Base.buffer_length",
"Prims.unit",
"FStar.UInt32.__uint_to_t",
"FStar.Seq.Base.slice",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"FStar.Pointer.Derived3.fill_buffer"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len
let sub_sub
(#a: typ)
(b: buffer a)
(i1: UInt32.t)
(len1: UInt32.t)
(i2: UInt32.t)
(len2: UInt32.t)
: Lemma
(requires (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1
))
(ensures (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\
gsub (gsub b i1 len1) i2 len2 == gsub b (UInt32.add i1 i2) len2
))
= ()
let sub_zero_length
(#a: typ)
(b: buffer a)
: Lemma
(ensures (gsub b (UInt32.uint_to_t 0) (UInt32.uint_to_t (length b)) == b))
= ()
let lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))]
]]
= Seq.lemma_eq_intro (as_seq h (gsub b i len)) (Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))
(* Same here *)
let goffset
(#a: typ)
(b: buffer a)
(i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures (fun b' ->
UInt32.v i <= length b /\
b' == gsub b i (UInt32.sub (P.buffer_length b) i)
))
= P.gsub_buffer b i (UInt32.sub (P.buffer_length b) i)
let offset
(#a:typ)
(b:buffer a)
(i:UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 ->
live h0 b /\
UInt32.v i <= length b
))
(ensures (fun h0 b' h1 ->
h1 == h0 /\
UInt32.v i <= length b /\
b' == goffset b i
))
= P.offset_buffer b i
let lemma_offset_spec
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i <= length b /\
live h b
))
(ensures (
UInt32.v i <= length b /\
as_seq h (goffset b i) == Seq.slice (as_seq h b) (UInt32.v i) (length b)
))
= ()
val eqb: #a:typ -> b1:buffer a -> b2:buffer a
-> len:UInt32.t
-> HST.ST bool
(requires (fun h ->
hasEq (P.type_of_typ a) /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
live h b1 /\
live h b2
))
(ensures (fun h0 z h1 ->
h1 == h0 /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
(z <==> equal h0 (gsub b1 0ul len) h0 (gsub b2 0ul len))
))
let eqb #a b1 b2 len =
P.buffer_contents_equal b1 b2 len
(* JP: if the [val] is not specified, there's an issue with these functions
* taking an extra unification parameter at extraction-time... *)
val op_Array_Access: #a:typ -> b:buffer a -> n:UInt32.t -> HST.Stack (P.type_of_typ a)
(requires (fun h -> UInt32.v n<length b /\ live h b))
(ensures (fun h0 z h1 -> h1 == h0 /\
UInt32.v n<length b /\
z == Seq.index (as_seq h0 b) (UInt32.v n)))
let op_Array_Access #a b n = index #a b n
val op_Array_Assignment: #a:typ -> b:buffer a -> n:UInt32.t -> z:P.type_of_typ a -> HST.Stack unit
(requires (fun h -> live h b /\ UInt32.v n < length b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ UInt32.v n < length b
/\ P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1
/\ as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z ))
let op_Array_Assignment #a b n z = upd #a b n z
val live_slice_middle
(#t: typ)
(b: buffer t)
(i: UInt32.t)
(len: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b 0ul i) /\
live h (gsub b i len) /\ (
let off = UInt32.add i len in
live h (gsub b off (UInt32.sub (P.buffer_length b) off))
)))
(ensures (live h b))
[SMTPat (live h (gsub b i len))]
let live_slice_middle #t b i len h =
P.buffer_readable_gsub_merge b i len h
(** Corresponds to memcpy *)
val blit: #t:typ
-> a:buffer t
-> idx_a:UInt32.t
-> b:buffer t{disjoint a b}
-> idx_b:UInt32.t
-> len:UInt32.t{UInt32.v idx_a + UInt32.v len <= length a /\ UInt32.v idx_b + UInt32.v len <= length b}
-> HST.Stack unit
(requires (fun h -> live h a /\ live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h0 a /\ live h1 b /\ live h1 a /\ P.modifies (P.loc_buffer (gsub b idx_b len)) h0 h1
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b) (UInt32.v idx_b + UInt32.v len) ==
Seq.slice (as_seq h0 a) (UInt32.v idx_a) (UInt32.v idx_a + UInt32.v len)
/\ Seq.slice (as_seq h1 b) 0 (UInt32.v idx_b) ==
Seq.slice (as_seq h0 b) 0 (UInt32.v idx_b)
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b+UInt32.v len) (length b) ==
Seq.slice (as_seq h0 b) (UInt32.v idx_b+UInt32.v len) (length b) ))
let blit #t a idx_a b idx_b len =
if len = 0ul
then ()
else begin
let h0 = HST.get () in
P.copy_buffer_contents a idx_a b idx_b len;
let h1 = HST.get () in
P.buffer_readable_modifies_gsub b idx_b len h0 h1 (P.loc_buffer (P.gsub_buffer b idx_b len));
assert (let g = (gsub b (UInt32.add idx_b len) (UInt32.sub (P.buffer_length b) (UInt32.add idx_b len))) in as_seq h1 g == as_seq h0 g);
assert (as_seq h1 (gsub b idx_b len) == as_seq h0 (gsub a idx_a len));
assert (let g = gsub b 0ul idx_b in as_seq h1 g == as_seq h0 g)
end
(** Corresponds to memset *)
val fill: #t:typ
-> b:buffer t
-> z: P.type_of_typ t
-> len:UInt32.t{UInt32.v len <= length b}
-> HST.Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\
P.modifies (P.loc_buffer (gsub b 0ul len)) h0 h1
/\ Seq.slice (as_seq h1 b) 0 (UInt32.v len) == Seq.create (UInt32.v len) z
/\ Seq.slice (as_seq h1 b) (UInt32.v len) (length b) ==
Seq.slice (as_seq h0 b) (UInt32.v len) (length b) )) | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 fill: #t:typ
-> b:buffer t
-> z: P.type_of_typ t
-> len:UInt32.t{UInt32.v len <= length b}
-> HST.Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\
P.modifies (P.loc_buffer (gsub b 0ul len)) h0 h1
/\ Seq.slice (as_seq h1 b) 0 (UInt32.v len) == Seq.create (UInt32.v len) z
/\ Seq.slice (as_seq h1 b) (UInt32.v len) (length b) ==
Seq.slice (as_seq h0 b) (UInt32.v len) (length b) )) | [] | FStar.BufferNG.fill | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
b: FStar.BufferNG.buffer t ->
z: FStar.Pointer.Base.type_of_typ t ->
len: FStar.UInt32.t{FStar.UInt32.v len <= FStar.BufferNG.length b}
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 96,
"end_line": 492,
"start_col": 21,
"start_line": 487
} |
FStar.HyperStack.ST.Stack | val blit: #t:typ
-> a:buffer t
-> idx_a:UInt32.t
-> b:buffer t{disjoint a b}
-> idx_b:UInt32.t
-> len:UInt32.t{UInt32.v idx_a + UInt32.v len <= length a /\ UInt32.v idx_b + UInt32.v len <= length b}
-> HST.Stack unit
(requires (fun h -> live h a /\ live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h0 a /\ live h1 b /\ live h1 a /\ P.modifies (P.loc_buffer (gsub b idx_b len)) h0 h1
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b) (UInt32.v idx_b + UInt32.v len) ==
Seq.slice (as_seq h0 a) (UInt32.v idx_a) (UInt32.v idx_a + UInt32.v len)
/\ Seq.slice (as_seq h1 b) 0 (UInt32.v idx_b) ==
Seq.slice (as_seq h0 b) 0 (UInt32.v idx_b)
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b+UInt32.v len) (length b) ==
Seq.slice (as_seq h0 b) (UInt32.v idx_b+UInt32.v len) (length b) )) | [
{
"abbrev": true,
"full_module": "FStar.Pointer",
"short_module": "P"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HH"
},
{
"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 blit #t a idx_a b idx_b len =
if len = 0ul
then ()
else begin
let h0 = HST.get () in
P.copy_buffer_contents a idx_a b idx_b len;
let h1 = HST.get () in
P.buffer_readable_modifies_gsub b idx_b len h0 h1 (P.loc_buffer (P.gsub_buffer b idx_b len));
assert (let g = (gsub b (UInt32.add idx_b len) (UInt32.sub (P.buffer_length b) (UInt32.add idx_b len))) in as_seq h1 g == as_seq h0 g);
assert (as_seq h1 (gsub b idx_b len) == as_seq h0 (gsub a idx_a len));
assert (let g = gsub b 0ul idx_b in as_seq h1 g == as_seq h0 g)
end | val blit: #t:typ
-> a:buffer t
-> idx_a:UInt32.t
-> b:buffer t{disjoint a b}
-> idx_b:UInt32.t
-> len:UInt32.t{UInt32.v idx_a + UInt32.v len <= length a /\ UInt32.v idx_b + UInt32.v len <= length b}
-> HST.Stack unit
(requires (fun h -> live h a /\ live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h0 a /\ live h1 b /\ live h1 a /\ P.modifies (P.loc_buffer (gsub b idx_b len)) h0 h1
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b) (UInt32.v idx_b + UInt32.v len) ==
Seq.slice (as_seq h0 a) (UInt32.v idx_a) (UInt32.v idx_a + UInt32.v len)
/\ Seq.slice (as_seq h1 b) 0 (UInt32.v idx_b) ==
Seq.slice (as_seq h0 b) 0 (UInt32.v idx_b)
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b+UInt32.v len) (length b) ==
Seq.slice (as_seq h0 b) (UInt32.v idx_b+UInt32.v len) (length b) ))
let blit #t a idx_a b idx_b len = | true | null | false | if len = 0ul
then ()
else
let h0 = HST.get () in
P.copy_buffer_contents a idx_a b idx_b len;
let h1 = HST.get () in
P.buffer_readable_modifies_gsub b idx_b len h0 h1 (P.loc_buffer (P.gsub_buffer b idx_b len));
assert (let g =
(gsub b (UInt32.add idx_b len) (UInt32.sub (P.buffer_length b) (UInt32.add idx_b len)))
in
as_seq h1 g == as_seq h0 g);
assert (as_seq h1 (gsub b idx_b len) == as_seq h0 (gsub a idx_a len));
assert (let g = gsub b 0ul idx_b in
as_seq h1 g == as_seq h0 g) | {
"checked_file": "FStar.BufferNG.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt.fsti.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pointer.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "FStar.BufferNG.fst"
} | [] | [
"FStar.BufferNG.typ",
"FStar.BufferNG.buffer",
"FStar.UInt32.t",
"FStar.BufferNG.disjoint",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.UInt32.v",
"FStar.BufferNG.length",
"Prims.op_Equality",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Prims.bool",
"Prims._assert",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.Pointer.Base.type_of_typ",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"FStar.BufferNG.as_seq",
"FStar.Pointer.Base.buffer",
"FStar.BufferNG.gsub",
"FStar.UInt32.add",
"FStar.UInt32.sub",
"FStar.Pointer.Base.buffer_length",
"FStar.Pointer.Derived1.buffer_readable_modifies_gsub",
"FStar.Pointer.Base.loc_buffer",
"FStar.Pointer.Base.gsub_buffer",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"FStar.Pointer.Derived2.copy_buffer_contents"
] | [] | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.BufferNG
module HH = FStar.HyperStack
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module P = FStar.Pointer
(* This module will help for the transition of some buffer-based code
It tries to sidestep the following two issues:
- the type of elements must be embeddable into P.typ
- all elements must always be readable (no uninitialized data)
*)
let rec supported
(t : P.typ)
: Tot bool
= match t with
| P.TBase _ -> true
| P.TStruct l -> struct_typ_supported l.P.fields
| _ -> false
and struct_typ_supported
(l: list (string * P.typ))
: Tot bool
= match l with
| [] -> true
| (_, t) :: l' -> supported t && struct_typ_supported l'
let typ = (t: P.typ { supported t } )
unfold
let buffer
(t: typ)
: Tot Type0
= P.buffer t
unfold
let live (#a: typ) (h: HS.mem) (b: buffer a) : GTot Type0 =
P.buffer_readable h b
unfold
let unused_in (#a: typ) (b: buffer a) (h: HS.mem) : GTot Type0 =
P.buffer_unused_in b h
unfold
let length (#a: typ) (b: buffer a) : GTot nat =
UInt32.v (P.buffer_length b)
unfold
let as_addr (#a: typ) (b: buffer a) : GTot nat =
P.buffer_as_addr b
unfold
let frameOf (#a: typ) (b: buffer a) : GTot HH.rid =
P.frameOf_buffer b
unfold
let as_seq (#a: typ) (h: HS.mem) (b: buffer a) : GTot (s: Seq.seq (P.type_of_typ a) { Seq.length s == length b } ) =
P.buffer_as_seq h b
unfold
let equal (#a: typ) (h: HS.mem) (b: buffer a) (h' : HS.mem) (b' : buffer a) : GTot Type0 =
as_seq h b == as_seq h' b'
unfold
let includes
(#a: typ)
(x y: buffer a)
: GTot Type0
= P.buffer_includes x y
let includes_live
(#a: typ)
(h: HS.mem)
(x y : buffer a)
: Lemma
(requires (x `includes` y /\ live h x))
(ensures (live h y))
= P.buffer_includes_elim x y
let includes_as_seq #a h1 h2 (x: buffer a) (y: buffer a)
: Lemma
(requires (x `includes` y /\ as_seq h1 x == as_seq h2 x))
(ensures (as_seq h1 y == as_seq h2 y))
= P.buffer_includes_elim x y
let includes_trans #a (x y z: buffer a)
: Lemma
(requires (x `includes` y /\ y `includes` z))
(ensures (x `includes` z))
= P.buffer_includes_trans x y z
unfold
let disjoint (#a #a' : typ) (x: buffer a) (y: buffer a') : GTot Type0 =
P.loc_disjoint (P.loc_buffer x) (P.loc_buffer y)
(* Disjointness is symmetric *)
let lemma_disjoint_symm #a #a' (x:buffer a) (y:buffer a') : Lemma
(requires True)
(ensures (disjoint x y <==> disjoint y x))
[SMTPat (disjoint x y)]
= ()
let lemma_disjoint_sub #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint subx y); SMTPat (includes x subx)]
= P.buffer_includes_loc_includes x subx;
P.loc_disjoint_includes (P.loc_buffer x) (P.loc_buffer y) (P.loc_buffer subx) (P.loc_buffer y)
let lemma_disjoint_sub' #a #a' (x:buffer a) (subx:buffer a) (y:buffer a') : Lemma
(requires (includes x subx /\ disjoint x y))
(ensures (disjoint subx y))
[SMTPat (disjoint y subx); SMTPat (includes x subx)]
= ()
let lemma_live_disjoint #a #a' h (b:buffer a) (b':buffer a') : Lemma
(requires (live h b /\ b' `unused_in` h))
(ensures (disjoint b b'))
[SMTPat (disjoint b b'); SMTPat (live h b)]
= ()
(** Concrete getters and setters *)
val create
(#a:typ)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.StackInline (buffer a)
(requires (fun h ->
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
UInt32.v len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let create #a init len =
let len : P.array_length_t = len in
let content = P.screate (P.TArray len a) (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
unfold let p (#a:typ) (init:list (P.type_of_typ a)) : GTot Type0 =
normalize (0 < FStar.List.Tot.length init) /\
normalize (FStar.List.Tot.length init < UInt.max_int 32)
unfold let q (#a:typ) (len:nat) (buf:buffer a) : GTot Type0 =
normalize (length buf == len)
val createL
(#a: typ)
(init:list (P.type_of_typ a))
: HST.StackInline (buffer a)
(requires (fun h -> p #a init))
(ensures (fun (h0: HS.mem) b h1 ->
let len = FStar.List.Tot.length init in
len > 0 /\
b `unused_in` h0 /\
live h1 b /\
length b == len /\
frameOf b == (HS.get_tip h0) /\
P.modifies_0 h0 h1 /\
as_seq h1 b == Seq.seq_of_list init /\
q #a len b
))
#set-options "--initial_fuel 1 --max_fuel 1" //the normalize_term (length init) in the pre-condition will be unfolded
//whereas the L.length init below will not
let createL #a init =
let len : P.array_length_t = UInt32.uint_to_t (List.Tot.length init) in
let s = Seq.seq_of_list init in
let content = P.screate (P.TArray len a) (Some s) in
P.buffer_of_array_pointer content
#reset-options "--initial_fuel 0 --max_fuel 0"
val rcreate
(#a: typ)
(r:HH.rid)
(init: P.type_of_typ a)
(len:UInt32.t)
: HST.ST (buffer a)
(requires (fun h ->
HST.is_eternal_region r /\
HST.witnessed (HST.region_contains_pred r) /\
UInt32.v len > 0
))
(ensures (fun (h0: HS.mem) b h1 ->
b `unused_in` h0 /\
live h1 b /\
length b == UInt32.v len /\
(HS.get_tip h1) == (HS.get_tip h0) /\
P.modifies (P.loc_addresses r Set.empty) h0 h1 /\
as_seq h1 b == Seq.create (UInt32.v len) init
))
let rcreate #a r init len =
let len : P.array_length_t = len in
let content = P.ecreate (P.TArray len a) r (Some (Seq.create (UInt32.v len) init)) in
P.buffer_of_array_pointer content
val index
(#a: typ)
(b: buffer a)
(n: UInt32.t)
: HST.Stack (P.type_of_typ a)
(requires (fun h ->
UInt32.v n < length b /\
live h b
))
(ensures (fun h0 z h1 ->
UInt32.v n < length b /\
h1 == h0 /\
z == Seq.index (as_seq h0 b) (UInt32.v n)
))
let index #a b n =
P.read_buffer b n
val upd
(#a: typ)
(b: buffer a)
(n: UInt32.t)
(z: P.type_of_typ a)
: HST.Stack unit
(requires (fun h ->
live h b /\
UInt32.v n < length b
))
(ensures (fun h0 _ h1 ->
live h1 b /\
UInt32.v n < length b /\
P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1 /\
as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z
))
let upd #a b n z =
let h0 = HST.get () in
P.write_buffer b n z;
let h1 = HST.get () in
assert (Seq.equal (as_seq h1 b) (Seq.upd (as_seq h0 b) (UInt32.v n) z))
(* NOTE: Here I cannot fully respect the Buffer interface,
because pure sub no longer exists, since it has been split
into ghost gsub and stateful sub
*)
unfold
let gsub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i + UInt32.v len <= length b))
(ensures (fun _ -> True))
= P.gsub_buffer b i len
let sub
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(len: UInt32.t)
: HST.Stack (buffer a)
(requires (fun h ->
live h b /\
UInt32.v i + UInt32.v len <= length b
))
(ensures (fun h0 b' h1 ->
live h0 b /\
UInt32.v i + UInt32.v len <= length b /\
h1 == h0 /\
b' == gsub b i len /\
b `includes` b'
))
= P.sub_buffer b i len
let sub_sub
(#a: typ)
(b: buffer a)
(i1: UInt32.t)
(len1: UInt32.t)
(i2: UInt32.t)
(len2: UInt32.t)
: Lemma
(requires (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1
))
(ensures (
UInt32.v i1 + UInt32.v len1 <= length b /\
UInt32.v i2 + UInt32.v len2 <= UInt32.v len1 /\
gsub (gsub b i1 len1) i2 len2 == gsub b (UInt32.add i1 i2) len2
))
= ()
let sub_zero_length
(#a: typ)
(b: buffer a)
: Lemma
(ensures (gsub b (UInt32.uint_to_t 0) (UInt32.uint_to_t (length b)) == b))
= ()
let lemma_sub_spec (#a:typ) (b:buffer a)
(i:UInt32.t)
(len:UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h b
))
(ensures (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b i len) /\
as_seq h (gsub b i len) == Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len)
))
[SMTPatOr [
[SMTPat (gsub b i len); SMTPat (live h b)];
[SMTPat (live h (gsub b i len))]
]]
= Seq.lemma_eq_intro (as_seq h (gsub b i len)) (Seq.slice (as_seq h b) (UInt32.v i) (UInt32.v i + UInt32.v len))
(* Same here *)
let goffset
(#a: typ)
(b: buffer a)
(i: UInt32.t)
: Ghost (buffer a)
(requires (UInt32.v i <= length b))
(ensures (fun b' ->
UInt32.v i <= length b /\
b' == gsub b i (UInt32.sub (P.buffer_length b) i)
))
= P.gsub_buffer b i (UInt32.sub (P.buffer_length b) i)
let offset
(#a:typ)
(b:buffer a)
(i:UInt32.t)
: HST.Stack (buffer a)
(requires (fun h0 ->
live h0 b /\
UInt32.v i <= length b
))
(ensures (fun h0 b' h1 ->
h1 == h0 /\
UInt32.v i <= length b /\
b' == goffset b i
))
= P.offset_buffer b i
let lemma_offset_spec
(#a: typ)
(b: buffer a)
(i: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i <= length b /\
live h b
))
(ensures (
UInt32.v i <= length b /\
as_seq h (goffset b i) == Seq.slice (as_seq h b) (UInt32.v i) (length b)
))
= ()
val eqb: #a:typ -> b1:buffer a -> b2:buffer a
-> len:UInt32.t
-> HST.ST bool
(requires (fun h ->
hasEq (P.type_of_typ a) /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
live h b1 /\
live h b2
))
(ensures (fun h0 z h1 ->
h1 == h0 /\
UInt32.v len <= length b1 /\
UInt32.v len <= length b2 /\
(z <==> equal h0 (gsub b1 0ul len) h0 (gsub b2 0ul len))
))
let eqb #a b1 b2 len =
P.buffer_contents_equal b1 b2 len
(* JP: if the [val] is not specified, there's an issue with these functions
* taking an extra unification parameter at extraction-time... *)
val op_Array_Access: #a:typ -> b:buffer a -> n:UInt32.t -> HST.Stack (P.type_of_typ a)
(requires (fun h -> UInt32.v n<length b /\ live h b))
(ensures (fun h0 z h1 -> h1 == h0 /\
UInt32.v n<length b /\
z == Seq.index (as_seq h0 b) (UInt32.v n)))
let op_Array_Access #a b n = index #a b n
val op_Array_Assignment: #a:typ -> b:buffer a -> n:UInt32.t -> z:P.type_of_typ a -> HST.Stack unit
(requires (fun h -> live h b /\ UInt32.v n < length b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ UInt32.v n < length b
/\ P.modifies (P.loc_pointer (P.gpointer_of_buffer_cell b n)) h0 h1
/\ as_seq h1 b == Seq.upd (as_seq h0 b) (UInt32.v n) z ))
let op_Array_Assignment #a b n z = upd #a b n z
val live_slice_middle
(#t: typ)
(b: buffer t)
(i: UInt32.t)
(len: UInt32.t)
(h: HS.mem)
: Lemma
(requires (
UInt32.v i + UInt32.v len <= length b /\
live h (gsub b 0ul i) /\
live h (gsub b i len) /\ (
let off = UInt32.add i len in
live h (gsub b off (UInt32.sub (P.buffer_length b) off))
)))
(ensures (live h b))
[SMTPat (live h (gsub b i len))]
let live_slice_middle #t b i len h =
P.buffer_readable_gsub_merge b i len h
(** Corresponds to memcpy *)
val blit: #t:typ
-> a:buffer t
-> idx_a:UInt32.t
-> b:buffer t{disjoint a b}
-> idx_b:UInt32.t
-> len:UInt32.t{UInt32.v idx_a + UInt32.v len <= length a /\ UInt32.v idx_b + UInt32.v len <= length b}
-> HST.Stack unit
(requires (fun h -> live h a /\ live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h0 a /\ live h1 b /\ live h1 a /\ P.modifies (P.loc_buffer (gsub b idx_b len)) h0 h1
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b) (UInt32.v idx_b + UInt32.v len) ==
Seq.slice (as_seq h0 a) (UInt32.v idx_a) (UInt32.v idx_a + UInt32.v len)
/\ Seq.slice (as_seq h1 b) 0 (UInt32.v idx_b) ==
Seq.slice (as_seq h0 b) 0 (UInt32.v idx_b)
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b+UInt32.v len) (length b) ==
Seq.slice (as_seq h0 b) (UInt32.v idx_b+UInt32.v len) (length b) )) | false | false | FStar.BufferNG.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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 blit: #t:typ
-> a:buffer t
-> idx_a:UInt32.t
-> b:buffer t{disjoint a b}
-> idx_b:UInt32.t
-> len:UInt32.t{UInt32.v idx_a + UInt32.v len <= length a /\ UInt32.v idx_b + UInt32.v len <= length b}
-> HST.Stack unit
(requires (fun h -> live h a /\ live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h0 a /\ live h1 b /\ live h1 a /\ P.modifies (P.loc_buffer (gsub b idx_b len)) h0 h1
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b) (UInt32.v idx_b + UInt32.v len) ==
Seq.slice (as_seq h0 a) (UInt32.v idx_a) (UInt32.v idx_a + UInt32.v len)
/\ Seq.slice (as_seq h1 b) 0 (UInt32.v idx_b) ==
Seq.slice (as_seq h0 b) 0 (UInt32.v idx_b)
/\ Seq.slice (as_seq h1 b) (UInt32.v idx_b+UInt32.v len) (length b) ==
Seq.slice (as_seq h0 b) (UInt32.v idx_b+UInt32.v len) (length b) )) | [] | FStar.BufferNG.blit | {
"file_name": "ulib/legacy/FStar.BufferNG.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} |
a: FStar.BufferNG.buffer t ->
idx_a: FStar.UInt32.t ->
b: FStar.BufferNG.buffer t {FStar.BufferNG.disjoint a b} ->
idx_b: FStar.UInt32.t ->
len:
FStar.UInt32.t
{ FStar.UInt32.v idx_a + FStar.UInt32.v len <= FStar.BufferNG.length a /\
FStar.UInt32.v idx_b + FStar.UInt32.v len <= FStar.BufferNG.length b }
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 5,
"end_line": 472,
"start_col": 2,
"start_line": 462
} |
FStar.HyperStack.ST.Stack | val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_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_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x | val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f = | true | null | false | [@@ inline_let ]let x =
(u64 0xe0cfc810b51283cf, u64 0xa880b9fc8ec739c2, u64 0x5ad9e3fd77ed9ba4, u64 0xac9c52b33fa3cf1f)
in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Hacl.K256.Scalar.make_u64_4",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.K256.GLV.minus_lambda",
"Hacl.K256.Scalar.qas_nat4",
"FStar.Pervasives.Native.tuple4",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntTypes.uint64",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda) | false | false | Hacl.Impl.K256.GLV.Constants.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 make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda) | [] | Hacl.Impl.K256.GLV.Constants.make_minus_lambda | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 16,
"end_line": 37,
"start_col": 2,
"start_line": 29
} |
FStar.HyperStack.ST.Stack | val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_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_g2 f =
[@inline_let]
let x =
(u64 0x1571b4ae8ac47f71,
u64 0x221208ac9df506c6,
u64 0x6f547fa90abfe4c4,
u64 0xe4437ed6010e8828) in
assert_norm (SG.g2 == qas_nat4 x);
make_u64_4 f x | val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2)
let make_g2 f = | true | null | false | [@@ inline_let ]let x =
(u64 0x1571b4ae8ac47f71, u64 0x221208ac9df506c6, u64 0x6f547fa90abfe4c4, u64 0xe4437ed6010e8828)
in
assert_norm (SG.g2 == qas_nat4 x);
make_u64_4 f x | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Hacl.K256.Scalar.make_u64_4",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.K256.GLV.g2",
"Hacl.K256.Scalar.qas_nat4",
"FStar.Pervasives.Native.tuple4",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntTypes.uint64",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1)
let make_g1 f =
[@inline_let]
let x =
(u64 0xe893209a45dbb031,
u64 0x3daa8a1471e8ca7f,
u64 0xe86c90e49284eb15,
u64 0x3086d221a7d46bcd) in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2) | false | false | Hacl.Impl.K256.GLV.Constants.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 make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2) | [] | Hacl.Impl.K256.GLV.Constants.make_g2 | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 16,
"end_line": 130,
"start_col": 2,
"start_line": 122
} |
FStar.HyperStack.ST.Stack | val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_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_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x | val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f = | true | null | false | [@@ inline_let ]let x = (u64 0x6f547fa90abfe4c3, u64 0xe4437ed6010e8828, u64 0x0, u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Hacl.K256.Scalar.make_u64_4",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.K256.GLV.minus_b1",
"Hacl.K256.Scalar.qas_nat4",
"FStar.Pervasives.Native.tuple4",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntTypes.uint64",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1) | false | false | Hacl.Impl.K256.GLV.Constants.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 make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1) | [] | Hacl.Impl.K256.GLV.Constants.make_minus_b1 | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 16,
"end_line": 76,
"start_col": 2,
"start_line": 68
} |
FStar.HyperStack.ST.Stack | val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_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_g1 f =
[@inline_let]
let x =
(u64 0xe893209a45dbb031,
u64 0x3daa8a1471e8ca7f,
u64 0xe86c90e49284eb15,
u64 0x3086d221a7d46bcd) in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x | val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1)
let make_g1 f = | true | null | false | [@@ inline_let ]let x =
(u64 0xe893209a45dbb031, u64 0x3daa8a1471e8ca7f, u64 0xe86c90e49284eb15, u64 0x3086d221a7d46bcd)
in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Hacl.K256.Scalar.make_u64_4",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.K256.GLV.g1",
"Hacl.K256.Scalar.qas_nat4",
"FStar.Pervasives.Native.tuple4",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntTypes.uint64",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1) | false | false | Hacl.Impl.K256.GLV.Constants.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 make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1) | [] | Hacl.Impl.K256.GLV.Constants.make_g1 | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 16,
"end_line": 112,
"start_col": 2,
"start_line": 104
} |
FStar.HyperStack.ST.Stack | val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_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_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x | val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f = | true | null | false | [@@ inline_let ]let x =
(u64 0xd765cda83db1562c, u64 0x8a280ac50774346d, u64 0xfffffffffffffffe, u64 0xffffffffffffffff)
in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Hacl.K256.Scalar.make_u64_4",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.int",
"Hacl.Spec.K256.GLV.minus_b2",
"Hacl.K256.Scalar.qas_nat4",
"FStar.Pervasives.Native.tuple4",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Pervasives.Native.Mktuple4",
"Lib.IntTypes.uint64",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2) | false | false | Hacl.Impl.K256.GLV.Constants.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 make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2) | [] | Hacl.Impl.K256.GLV.Constants.make_minus_b2 | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.K256.Scalar.qelem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 16,
"end_line": 94,
"start_col": 2,
"start_line": 86
} |
FStar.HyperStack.ST.Stack | val scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2)) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k =
make_g1 tmp1; // tmp1 = g1
make_g2 tmp2; // tmp2 = g2
qmul_shift_384 r1 k tmp1; // r1 = c1 = qmul_shift_384 k g1
qmul_shift_384 r2 k tmp2; // r2 = c2 = qmul_shift_384 k g2
let h0 = ST.get () in
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp1);
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp2);
assert (qas_nat h0 r1 < S.q /\ qas_nat h0 r2 < S.q) | val scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2))
let scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k = | true | null | false | make_g1 tmp1;
make_g2 tmp2;
qmul_shift_384 r1 k tmp1;
qmul_shift_384 r2 k tmp2;
let h0 = ST.get () in
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp1);
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp2);
assert (qas_nat h0 r1 < S.q /\ qas_nat h0 r2 < S.q) | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Prims._assert",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.K256.Scalar.qas_nat",
"Spec.K256.PointOps.q",
"Prims.unit",
"Hacl.Spec.K256.GLV.qmul_shift_384_lemma",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Hacl.K256.Scalar.qmul_shift_384",
"Hacl.Impl.K256.GLV.Constants.make_g2",
"Hacl.Impl.K256.GLV.Constants.make_g1"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1)
let make_g1 f =
[@inline_let]
let x =
(u64 0xe893209a45dbb031,
u64 0x3daa8a1471e8ca7f,
u64 0xe86c90e49284eb15,
u64 0x3086d221a7d46bcd) in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2)
let make_g2 f =
[@inline_let]
let x =
(u64 0x1571b4ae8ac47f71,
u64 0x221208ac9df506c6,
u64 0x6f547fa90abfe4c4,
u64 0xe4437ed6010e8828) in
assert_norm (SG.g2 == qas_nat4 x);
make_u64_4 f x
(**
Representing a scalar k as (r1 + r2 * lambda) mod S.q,
s.t. r1 and r2 are ~128 bits long
*)
inline_for_extraction noextract
val scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2)) | false | false | Hacl.Impl.K256.GLV.Constants.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 scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2)) | [] | Hacl.Impl.K256.GLV.Constants.scalar_split_lambda_g1g2 | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
tmp1: Hacl.K256.Scalar.qelem ->
tmp2: Hacl.K256.Scalar.qelem ->
r1: Hacl.K256.Scalar.qelem ->
r2: Hacl.K256.Scalar.qelem ->
k: Hacl.K256.Scalar.qelem
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 53,
"end_line": 161,
"start_col": 2,
"start_line": 154
} |
FStar.HyperStack.ST.Stack | val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_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_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x | val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f = | true | null | false | [@@ inline_let ]let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c)
in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Field.felem",
"Hacl.K256.Field.make_u52_5",
"Prims.unit",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.nat",
"Hacl.Spec.K256.GLV.beta",
"Hacl.Spec.K256.Field52.Definitions.as_nat5",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Hacl.Spec.K256.Field52.Definitions.max48",
"Hacl.Spec.K256.Field52.Definitions.max52",
"FStar.Pervasives.Native.tuple5",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.SEC",
"FStar.Pervasives.Native.Mktuple5",
"Lib.IntTypes.uint64",
"Lib.IntTypes.u64"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f) | false | false | Hacl.Impl.K256.GLV.Constants.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 make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f) | [] | Hacl.Impl.K256.GLV.Constants.make_beta | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | f: Hacl.K256.Field.felem -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 16,
"end_line": 58,
"start_col": 2,
"start_line": 47
} |
FStar.HyperStack.ST.Stack | val point_mul_lambda_and_split_lambda:
r1:qelem -> r2:qelem -> lambda_q:point -> scalar:qelem -> q:point -> Stack unit
(requires fun h ->
live h r1 /\ live h r2 /\ live h lambda_q /\ live h scalar /\ live h q /\
disjoint r1 r2 /\ disjoint r1 lambda_q /\ disjoint r1 scalar /\ disjoint r1 q /\
disjoint r2 lambda_q /\ disjoint r2 scalar /\ disjoint r2 q /\
disjoint lambda_q scalar /\ disjoint lambda_q q /\
point_inv h q /\ qas_nat h scalar < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2 |+| loc lambda_q) h0 h1 /\
point_inv h1 lambda_q /\
point_eval h1 lambda_q == SG.point_mul_lambda (point_eval h0 q) /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 scalar) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s)) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_mul_lambda_and_split_lambda r1 r2 lambda_q scalar q =
scalar_split_lambda r1 r2 scalar; // (r1 + r2 * lambda) % S.q = scalar
point_mul_lambda lambda_q q | val point_mul_lambda_and_split_lambda:
r1:qelem -> r2:qelem -> lambda_q:point -> scalar:qelem -> q:point -> Stack unit
(requires fun h ->
live h r1 /\ live h r2 /\ live h lambda_q /\ live h scalar /\ live h q /\
disjoint r1 r2 /\ disjoint r1 lambda_q /\ disjoint r1 scalar /\ disjoint r1 q /\
disjoint r2 lambda_q /\ disjoint r2 scalar /\ disjoint r2 q /\
disjoint lambda_q scalar /\ disjoint lambda_q q /\
point_inv h q /\ qas_nat h scalar < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2 |+| loc lambda_q) h0 h1 /\
point_inv h1 lambda_q /\
point_eval h1 lambda_q == SG.point_mul_lambda (point_eval h0 q) /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 scalar) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
let point_mul_lambda_and_split_lambda r1 r2 lambda_q scalar q = | true | null | false | scalar_split_lambda r1 r2 scalar;
point_mul_lambda lambda_q q | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Hacl.Impl.K256.Point.point",
"Hacl.Impl.K256.GLV.Constants.point_mul_lambda",
"Prims.unit",
"Hacl.Impl.K256.GLV.Constants.scalar_split_lambda"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1)
let make_g1 f =
[@inline_let]
let x =
(u64 0xe893209a45dbb031,
u64 0x3daa8a1471e8ca7f,
u64 0xe86c90e49284eb15,
u64 0x3086d221a7d46bcd) in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2)
let make_g2 f =
[@inline_let]
let x =
(u64 0x1571b4ae8ac47f71,
u64 0x221208ac9df506c6,
u64 0x6f547fa90abfe4c4,
u64 0xe4437ed6010e8828) in
assert_norm (SG.g2 == qas_nat4 x);
make_u64_4 f x
(**
Representing a scalar k as (r1 + r2 * lambda) mod S.q,
s.t. r1 and r2 are ~128 bits long
*)
inline_for_extraction noextract
val scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2))
let scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k =
make_g1 tmp1; // tmp1 = g1
make_g2 tmp2; // tmp2 = g2
qmul_shift_384 r1 k tmp1; // r1 = c1 = qmul_shift_384 k g1
qmul_shift_384 r2 k tmp2; // r2 = c2 = qmul_shift_384 k g2
let h0 = ST.get () in
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp1);
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp2);
assert (qas_nat h0 r1 < S.q /\ qas_nat h0 r2 < S.q)
// k = (r1 + lambda * k2) % S.q
val scalar_split_lambda (r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
qas_nat h k < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2) h0 h1 /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 k) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
[@CInline]
let scalar_split_lambda r1 r2 k =
push_frame ();
let tmp1 = create_qelem () in
let tmp2 = create_qelem () in
scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k;
make_minus_b1 tmp1; // tmp1 = minus_b1
make_minus_b2 tmp2; // tmp2 = minus_b2
qmul r1 r1 tmp1; // r1 = c1 = c1 * minus_b1
qmul r2 r2 tmp2; // r2 = c2 = c2 * minus_b2
make_minus_lambda tmp1; // tmp1 = minus_lambda
qadd r2 r1 r2; // r2 = r2 = c1 + c2
qmul tmp2 r2 tmp1; // tmp2 = r2 * minus_lambda
qadd r1 k tmp2; // r1 = r1 = k + r2 * minus_lambda
pop_frame ()
(**
Fast computation of [lambda]P as (beta * px, py, pz) in projective coordinates
*)
[@CInline]
let point_mul_lambda res p =
push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let px, py, pz = getx p, gety p, getz p in
let beta = create_felem () in
make_beta beta;
fmul rx beta px;
copy_felem ry py;
copy_felem rz pz;
pop_frame ()
[@CInline]
let point_mul_lambda_inplace res =
push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let beta = create_felem () in
make_beta beta;
fmul rx beta rx;
pop_frame ()
inline_for_extraction noextract
val point_mul_lambda_and_split_lambda:
r1:qelem -> r2:qelem -> lambda_q:point -> scalar:qelem -> q:point -> Stack unit
(requires fun h ->
live h r1 /\ live h r2 /\ live h lambda_q /\ live h scalar /\ live h q /\
disjoint r1 r2 /\ disjoint r1 lambda_q /\ disjoint r1 scalar /\ disjoint r1 q /\
disjoint r2 lambda_q /\ disjoint r2 scalar /\ disjoint r2 q /\
disjoint lambda_q scalar /\ disjoint lambda_q q /\
point_inv h q /\ qas_nat h scalar < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2 |+| loc lambda_q) h0 h1 /\
point_inv h1 lambda_q /\
point_eval h1 lambda_q == SG.point_mul_lambda (point_eval h0 q) /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 scalar) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s)) | false | false | Hacl.Impl.K256.GLV.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_mul_lambda_and_split_lambda:
r1:qelem -> r2:qelem -> lambda_q:point -> scalar:qelem -> q:point -> Stack unit
(requires fun h ->
live h r1 /\ live h r2 /\ live h lambda_q /\ live h scalar /\ live h q /\
disjoint r1 r2 /\ disjoint r1 lambda_q /\ disjoint r1 scalar /\ disjoint r1 q /\
disjoint r2 lambda_q /\ disjoint r2 scalar /\ disjoint r2 q /\
disjoint lambda_q scalar /\ disjoint lambda_q q /\
point_inv h q /\ qas_nat h scalar < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2 |+| loc lambda_q) h0 h1 /\
point_inv h1 lambda_q /\
point_eval h1 lambda_q == SG.point_mul_lambda (point_eval h0 q) /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 scalar) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s)) | [] | Hacl.Impl.K256.GLV.Constants.point_mul_lambda_and_split_lambda | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
r1: Hacl.K256.Scalar.qelem ->
r2: Hacl.K256.Scalar.qelem ->
lambda_q: Hacl.Impl.K256.Point.point ->
scalar: Hacl.K256.Scalar.qelem ->
q: Hacl.Impl.K256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 29,
"end_line": 238,
"start_col": 2,
"start_line": 237
} |
FStar.HyperStack.ST.Stack | val point_mul_lambda_inplace: res:point -> Stack unit
(requires fun h ->
live h res /\ point_inv h res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
point_eval h1 res == SG.point_mul_lambda (point_eval h0 res)) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_mul_lambda_inplace res =
push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let beta = create_felem () in
make_beta beta;
fmul rx beta rx;
pop_frame () | val point_mul_lambda_inplace: res:point -> Stack unit
(requires fun h ->
live h res /\ point_inv h res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
point_eval h1 res == SG.point_mul_lambda (point_eval h0 res))
let point_mul_lambda_inplace res = | true | null | false | push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let beta = create_felem () in
make_beta beta;
fmul rx beta rx;
pop_frame () | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.Impl.K256.Point.point",
"Hacl.K256.Field.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.K256.Field.fmul",
"Hacl.Impl.K256.GLV.Constants.make_beta",
"Hacl.K256.Field.create_felem",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"Hacl.Impl.K256.Point.getz",
"Hacl.Impl.K256.Point.gety",
"Hacl.Impl.K256.Point.getx",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1)
let make_g1 f =
[@inline_let]
let x =
(u64 0xe893209a45dbb031,
u64 0x3daa8a1471e8ca7f,
u64 0xe86c90e49284eb15,
u64 0x3086d221a7d46bcd) in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2)
let make_g2 f =
[@inline_let]
let x =
(u64 0x1571b4ae8ac47f71,
u64 0x221208ac9df506c6,
u64 0x6f547fa90abfe4c4,
u64 0xe4437ed6010e8828) in
assert_norm (SG.g2 == qas_nat4 x);
make_u64_4 f x
(**
Representing a scalar k as (r1 + r2 * lambda) mod S.q,
s.t. r1 and r2 are ~128 bits long
*)
inline_for_extraction noextract
val scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2))
let scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k =
make_g1 tmp1; // tmp1 = g1
make_g2 tmp2; // tmp2 = g2
qmul_shift_384 r1 k tmp1; // r1 = c1 = qmul_shift_384 k g1
qmul_shift_384 r2 k tmp2; // r2 = c2 = qmul_shift_384 k g2
let h0 = ST.get () in
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp1);
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp2);
assert (qas_nat h0 r1 < S.q /\ qas_nat h0 r2 < S.q)
// k = (r1 + lambda * k2) % S.q
val scalar_split_lambda (r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
qas_nat h k < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2) h0 h1 /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 k) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
[@CInline]
let scalar_split_lambda r1 r2 k =
push_frame ();
let tmp1 = create_qelem () in
let tmp2 = create_qelem () in
scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k;
make_minus_b1 tmp1; // tmp1 = minus_b1
make_minus_b2 tmp2; // tmp2 = minus_b2
qmul r1 r1 tmp1; // r1 = c1 = c1 * minus_b1
qmul r2 r2 tmp2; // r2 = c2 = c2 * minus_b2
make_minus_lambda tmp1; // tmp1 = minus_lambda
qadd r2 r1 r2; // r2 = r2 = c1 + c2
qmul tmp2 r2 tmp1; // tmp2 = r2 * minus_lambda
qadd r1 k tmp2; // r1 = r1 = k + r2 * minus_lambda
pop_frame ()
(**
Fast computation of [lambda]P as (beta * px, py, pz) in projective coordinates
*)
[@CInline]
let point_mul_lambda res p =
push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let px, py, pz = getx p, gety p, getz p in
let beta = create_felem () in
make_beta beta;
fmul rx beta px;
copy_felem ry py;
copy_felem rz pz;
pop_frame ()
[@CInline] | false | false | Hacl.Impl.K256.GLV.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_mul_lambda_inplace: res:point -> Stack unit
(requires fun h ->
live h res /\ point_inv h res)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
point_eval h1 res == SG.point_mul_lambda (point_eval h0 res)) | [] | Hacl.Impl.K256.GLV.Constants.point_mul_lambda_inplace | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | res: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 218,
"start_col": 2,
"start_line": 213
} |
FStar.HyperStack.ST.Stack | val negate_point_and_scalar_cond_vartime: k:qelem -> p:point -> Stack bool
(requires fun h ->
live h k /\ live h p /\ disjoint k p /\
qas_nat h k < S.q /\ point_inv h p)
(ensures fun h0 b h1 -> modifies (loc k |+| loc p) h0 h1 /\
b == S.scalar_is_high (qas_nat h0 k) /\ point_inv h1 p /\
(let k_s, p_s = SG.negate_point_and_scalar_cond (qas_nat h0 k) (point_eval h0 p) in
qas_nat h1 k == k_s /\ point_eval h1 p == p_s)) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let negate_point_and_scalar_cond_vartime k p =
let b = is_qelem_le_q_halved_vartime k in
[@inline_let] let if_high = not b in
qnegate_conditional_vartime k if_high;
point_negate_conditional_vartime p if_high;
if_high | val negate_point_and_scalar_cond_vartime: k:qelem -> p:point -> Stack bool
(requires fun h ->
live h k /\ live h p /\ disjoint k p /\
qas_nat h k < S.q /\ point_inv h p)
(ensures fun h0 b h1 -> modifies (loc k |+| loc p) h0 h1 /\
b == S.scalar_is_high (qas_nat h0 k) /\ point_inv h1 p /\
(let k_s, p_s = SG.negate_point_and_scalar_cond (qas_nat h0 k) (point_eval h0 p) in
qas_nat h1 k == k_s /\ point_eval h1 p == p_s))
let negate_point_and_scalar_cond_vartime k p = | true | null | false | let b = is_qelem_le_q_halved_vartime k in
[@@ inline_let ]let if_high = not b in
qnegate_conditional_vartime k if_high;
point_negate_conditional_vartime p if_high;
if_high | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Hacl.Impl.K256.Point.point",
"Prims.bool",
"Prims.unit",
"Hacl.Impl.K256.Point.point_negate_conditional_vartime",
"Hacl.K256.Scalar.qnegate_conditional_vartime",
"Prims.op_Negation",
"Hacl.K256.Scalar.is_qelem_le_q_halved_vartime"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1)
let make_g1 f =
[@inline_let]
let x =
(u64 0xe893209a45dbb031,
u64 0x3daa8a1471e8ca7f,
u64 0xe86c90e49284eb15,
u64 0x3086d221a7d46bcd) in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2)
let make_g2 f =
[@inline_let]
let x =
(u64 0x1571b4ae8ac47f71,
u64 0x221208ac9df506c6,
u64 0x6f547fa90abfe4c4,
u64 0xe4437ed6010e8828) in
assert_norm (SG.g2 == qas_nat4 x);
make_u64_4 f x
(**
Representing a scalar k as (r1 + r2 * lambda) mod S.q,
s.t. r1 and r2 are ~128 bits long
*)
inline_for_extraction noextract
val scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2))
let scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k =
make_g1 tmp1; // tmp1 = g1
make_g2 tmp2; // tmp2 = g2
qmul_shift_384 r1 k tmp1; // r1 = c1 = qmul_shift_384 k g1
qmul_shift_384 r2 k tmp2; // r2 = c2 = qmul_shift_384 k g2
let h0 = ST.get () in
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp1);
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp2);
assert (qas_nat h0 r1 < S.q /\ qas_nat h0 r2 < S.q)
// k = (r1 + lambda * k2) % S.q
val scalar_split_lambda (r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
qas_nat h k < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2) h0 h1 /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 k) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
[@CInline]
let scalar_split_lambda r1 r2 k =
push_frame ();
let tmp1 = create_qelem () in
let tmp2 = create_qelem () in
scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k;
make_minus_b1 tmp1; // tmp1 = minus_b1
make_minus_b2 tmp2; // tmp2 = minus_b2
qmul r1 r1 tmp1; // r1 = c1 = c1 * minus_b1
qmul r2 r2 tmp2; // r2 = c2 = c2 * minus_b2
make_minus_lambda tmp1; // tmp1 = minus_lambda
qadd r2 r1 r2; // r2 = r2 = c1 + c2
qmul tmp2 r2 tmp1; // tmp2 = r2 * minus_lambda
qadd r1 k tmp2; // r1 = r1 = k + r2 * minus_lambda
pop_frame ()
(**
Fast computation of [lambda]P as (beta * px, py, pz) in projective coordinates
*)
[@CInline]
let point_mul_lambda res p =
push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let px, py, pz = getx p, gety p, getz p in
let beta = create_felem () in
make_beta beta;
fmul rx beta px;
copy_felem ry py;
copy_felem rz pz;
pop_frame ()
[@CInline]
let point_mul_lambda_inplace res =
push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let beta = create_felem () in
make_beta beta;
fmul rx beta rx;
pop_frame ()
inline_for_extraction noextract
val point_mul_lambda_and_split_lambda:
r1:qelem -> r2:qelem -> lambda_q:point -> scalar:qelem -> q:point -> Stack unit
(requires fun h ->
live h r1 /\ live h r2 /\ live h lambda_q /\ live h scalar /\ live h q /\
disjoint r1 r2 /\ disjoint r1 lambda_q /\ disjoint r1 scalar /\ disjoint r1 q /\
disjoint r2 lambda_q /\ disjoint r2 scalar /\ disjoint r2 q /\
disjoint lambda_q scalar /\ disjoint lambda_q q /\
point_inv h q /\ qas_nat h scalar < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2 |+| loc lambda_q) h0 h1 /\
point_inv h1 lambda_q /\
point_eval h1 lambda_q == SG.point_mul_lambda (point_eval h0 q) /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 scalar) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
let point_mul_lambda_and_split_lambda r1 r2 lambda_q scalar q =
scalar_split_lambda r1 r2 scalar; // (r1 + r2 * lambda) % S.q = scalar
point_mul_lambda lambda_q q // lambda_q = [lambda]Q
inline_for_extraction noextract
val negate_point_and_scalar_cond_vartime: k:qelem -> p:point -> Stack bool
(requires fun h ->
live h k /\ live h p /\ disjoint k p /\
qas_nat h k < S.q /\ point_inv h p)
(ensures fun h0 b h1 -> modifies (loc k |+| loc p) h0 h1 /\
b == S.scalar_is_high (qas_nat h0 k) /\ point_inv h1 p /\
(let k_s, p_s = SG.negate_point_and_scalar_cond (qas_nat h0 k) (point_eval h0 p) in
qas_nat h1 k == k_s /\ point_eval h1 p == p_s)) | false | false | Hacl.Impl.K256.GLV.Constants.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 negate_point_and_scalar_cond_vartime: k:qelem -> p:point -> Stack bool
(requires fun h ->
live h k /\ live h p /\ disjoint k p /\
qas_nat h k < S.q /\ point_inv h p)
(ensures fun h0 b h1 -> modifies (loc k |+| loc p) h0 h1 /\
b == S.scalar_is_high (qas_nat h0 k) /\ point_inv h1 p /\
(let k_s, p_s = SG.negate_point_and_scalar_cond (qas_nat h0 k) (point_eval h0 p) in
qas_nat h1 k == k_s /\ point_eval h1 p == p_s)) | [] | Hacl.Impl.K256.GLV.Constants.negate_point_and_scalar_cond_vartime | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | k: Hacl.K256.Scalar.qelem -> p: Hacl.Impl.K256.Point.point -> FStar.HyperStack.ST.Stack Prims.bool | {
"end_col": 9,
"end_line": 256,
"start_col": 46,
"start_line": 251
} |
FStar.HyperStack.ST.Stack | val ecmult_endo_split:
r1:qelem -> r2:qelem
-> q1:point -> q2:point
-> scalar:qelem -> q:point -> Stack (bool & bool)
(requires fun h ->
live h r1 /\ live h r2 /\ live h q1 /\
live h q2 /\ live h scalar /\ live h q /\
disjoint r1 r2 /\ disjoint r1 q1 /\ disjoint r1 q2 /\
disjoint r1 scalar /\ disjoint r1 q /\ disjoint r2 q1 /\
disjoint r2 q2 /\ disjoint r2 scalar /\ disjoint r2 q /\
disjoint q1 q2 /\ disjoint q1 scalar /\ disjoint q1 q /\
disjoint q2 scalar /\ disjoint q2 q /\
point_inv h q /\ qas_nat h scalar < S.q)
(ensures fun h0 (is_high1, is_high2) h1 ->
modifies (loc r1 |+| loc r2 |+| loc q1 |+| loc q2) h0 h1 /\
point_inv h1 q1 /\ point_inv h1 q2 /\
(let r1_s0, r2_s0 = SG.scalar_split_lambda (qas_nat h0 scalar) in
let r1_s, q1_s, r2_s, q2_s = SG.ecmult_endo_split (qas_nat h0 scalar) (point_eval h0 q) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s /\
point_eval h1 q1 == q1_s /\ point_eval h1 q2 == q2_s /\
is_high1 == S.scalar_is_high r1_s0 /\
is_high2 == S.scalar_is_high r2_s0)) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let ecmult_endo_split r1 r2 q1 q2 scalar q =
let h0 = ST.get () in
// modifies r1, r2, q2 s.t. r1 + r2 * lambda = scalar /\ q2 = [lambda]q
point_mul_lambda_and_split_lambda r1 r2 q2 scalar q;
copy q1 q; // q1 = q
// modifies r1, q1
let is_high1 = negate_point_and_scalar_cond_vartime r1 q1 in
// modifies r2, q2
let is_high2 = negate_point_and_scalar_cond_vartime r2 q2 in
is_high1, is_high2 | val ecmult_endo_split:
r1:qelem -> r2:qelem
-> q1:point -> q2:point
-> scalar:qelem -> q:point -> Stack (bool & bool)
(requires fun h ->
live h r1 /\ live h r2 /\ live h q1 /\
live h q2 /\ live h scalar /\ live h q /\
disjoint r1 r2 /\ disjoint r1 q1 /\ disjoint r1 q2 /\
disjoint r1 scalar /\ disjoint r1 q /\ disjoint r2 q1 /\
disjoint r2 q2 /\ disjoint r2 scalar /\ disjoint r2 q /\
disjoint q1 q2 /\ disjoint q1 scalar /\ disjoint q1 q /\
disjoint q2 scalar /\ disjoint q2 q /\
point_inv h q /\ qas_nat h scalar < S.q)
(ensures fun h0 (is_high1, is_high2) h1 ->
modifies (loc r1 |+| loc r2 |+| loc q1 |+| loc q2) h0 h1 /\
point_inv h1 q1 /\ point_inv h1 q2 /\
(let r1_s0, r2_s0 = SG.scalar_split_lambda (qas_nat h0 scalar) in
let r1_s, q1_s, r2_s, q2_s = SG.ecmult_endo_split (qas_nat h0 scalar) (point_eval h0 q) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s /\
point_eval h1 q1 == q1_s /\ point_eval h1 q2 == q2_s /\
is_high1 == S.scalar_is_high r1_s0 /\
is_high2 == S.scalar_is_high r2_s0))
let ecmult_endo_split r1 r2 q1 q2 scalar q = | true | null | false | let h0 = ST.get () in
point_mul_lambda_and_split_lambda r1 r2 q2 scalar q;
copy q1 q;
let is_high1 = negate_point_and_scalar_cond_vartime r1 q1 in
let is_high2 = negate_point_and_scalar_cond_vartime r2 q2 in
is_high1, is_high2 | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"Hacl.Impl.K256.Point.point",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"FStar.Pervasives.Native.tuple2",
"Hacl.Impl.K256.GLV.Constants.negate_point_and_scalar_cond_vartime",
"Prims.unit",
"Lib.Buffer.copy",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint64",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.K256.GLV.Constants.point_mul_lambda_and_split_lambda",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1)
let make_g1 f =
[@inline_let]
let x =
(u64 0xe893209a45dbb031,
u64 0x3daa8a1471e8ca7f,
u64 0xe86c90e49284eb15,
u64 0x3086d221a7d46bcd) in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2)
let make_g2 f =
[@inline_let]
let x =
(u64 0x1571b4ae8ac47f71,
u64 0x221208ac9df506c6,
u64 0x6f547fa90abfe4c4,
u64 0xe4437ed6010e8828) in
assert_norm (SG.g2 == qas_nat4 x);
make_u64_4 f x
(**
Representing a scalar k as (r1 + r2 * lambda) mod S.q,
s.t. r1 and r2 are ~128 bits long
*)
inline_for_extraction noextract
val scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2))
let scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k =
make_g1 tmp1; // tmp1 = g1
make_g2 tmp2; // tmp2 = g2
qmul_shift_384 r1 k tmp1; // r1 = c1 = qmul_shift_384 k g1
qmul_shift_384 r2 k tmp2; // r2 = c2 = qmul_shift_384 k g2
let h0 = ST.get () in
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp1);
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp2);
assert (qas_nat h0 r1 < S.q /\ qas_nat h0 r2 < S.q)
// k = (r1 + lambda * k2) % S.q
val scalar_split_lambda (r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
qas_nat h k < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2) h0 h1 /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 k) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
[@CInline]
let scalar_split_lambda r1 r2 k =
push_frame ();
let tmp1 = create_qelem () in
let tmp2 = create_qelem () in
scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k;
make_minus_b1 tmp1; // tmp1 = minus_b1
make_minus_b2 tmp2; // tmp2 = minus_b2
qmul r1 r1 tmp1; // r1 = c1 = c1 * minus_b1
qmul r2 r2 tmp2; // r2 = c2 = c2 * minus_b2
make_minus_lambda tmp1; // tmp1 = minus_lambda
qadd r2 r1 r2; // r2 = r2 = c1 + c2
qmul tmp2 r2 tmp1; // tmp2 = r2 * minus_lambda
qadd r1 k tmp2; // r1 = r1 = k + r2 * minus_lambda
pop_frame ()
(**
Fast computation of [lambda]P as (beta * px, py, pz) in projective coordinates
*)
[@CInline]
let point_mul_lambda res p =
push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let px, py, pz = getx p, gety p, getz p in
let beta = create_felem () in
make_beta beta;
fmul rx beta px;
copy_felem ry py;
copy_felem rz pz;
pop_frame ()
[@CInline]
let point_mul_lambda_inplace res =
push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let beta = create_felem () in
make_beta beta;
fmul rx beta rx;
pop_frame ()
inline_for_extraction noextract
val point_mul_lambda_and_split_lambda:
r1:qelem -> r2:qelem -> lambda_q:point -> scalar:qelem -> q:point -> Stack unit
(requires fun h ->
live h r1 /\ live h r2 /\ live h lambda_q /\ live h scalar /\ live h q /\
disjoint r1 r2 /\ disjoint r1 lambda_q /\ disjoint r1 scalar /\ disjoint r1 q /\
disjoint r2 lambda_q /\ disjoint r2 scalar /\ disjoint r2 q /\
disjoint lambda_q scalar /\ disjoint lambda_q q /\
point_inv h q /\ qas_nat h scalar < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2 |+| loc lambda_q) h0 h1 /\
point_inv h1 lambda_q /\
point_eval h1 lambda_q == SG.point_mul_lambda (point_eval h0 q) /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 scalar) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
let point_mul_lambda_and_split_lambda r1 r2 lambda_q scalar q =
scalar_split_lambda r1 r2 scalar; // (r1 + r2 * lambda) % S.q = scalar
point_mul_lambda lambda_q q // lambda_q = [lambda]Q
inline_for_extraction noextract
val negate_point_and_scalar_cond_vartime: k:qelem -> p:point -> Stack bool
(requires fun h ->
live h k /\ live h p /\ disjoint k p /\
qas_nat h k < S.q /\ point_inv h p)
(ensures fun h0 b h1 -> modifies (loc k |+| loc p) h0 h1 /\
b == S.scalar_is_high (qas_nat h0 k) /\ point_inv h1 p /\
(let k_s, p_s = SG.negate_point_and_scalar_cond (qas_nat h0 k) (point_eval h0 p) in
qas_nat h1 k == k_s /\ point_eval h1 p == p_s))
let negate_point_and_scalar_cond_vartime k p =
let b = is_qelem_le_q_halved_vartime k in
[@inline_let] let if_high = not b in
qnegate_conditional_vartime k if_high;
point_negate_conditional_vartime p if_high;
if_high | false | false | Hacl.Impl.K256.GLV.Constants.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 ecmult_endo_split:
r1:qelem -> r2:qelem
-> q1:point -> q2:point
-> scalar:qelem -> q:point -> Stack (bool & bool)
(requires fun h ->
live h r1 /\ live h r2 /\ live h q1 /\
live h q2 /\ live h scalar /\ live h q /\
disjoint r1 r2 /\ disjoint r1 q1 /\ disjoint r1 q2 /\
disjoint r1 scalar /\ disjoint r1 q /\ disjoint r2 q1 /\
disjoint r2 q2 /\ disjoint r2 scalar /\ disjoint r2 q /\
disjoint q1 q2 /\ disjoint q1 scalar /\ disjoint q1 q /\
disjoint q2 scalar /\ disjoint q2 q /\
point_inv h q /\ qas_nat h scalar < S.q)
(ensures fun h0 (is_high1, is_high2) h1 ->
modifies (loc r1 |+| loc r2 |+| loc q1 |+| loc q2) h0 h1 /\
point_inv h1 q1 /\ point_inv h1 q2 /\
(let r1_s0, r2_s0 = SG.scalar_split_lambda (qas_nat h0 scalar) in
let r1_s, q1_s, r2_s, q2_s = SG.ecmult_endo_split (qas_nat h0 scalar) (point_eval h0 q) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s /\
point_eval h1 q1 == q1_s /\ point_eval h1 q2 == q2_s /\
is_high1 == S.scalar_is_high r1_s0 /\
is_high2 == S.scalar_is_high r2_s0)) | [] | Hacl.Impl.K256.GLV.Constants.ecmult_endo_split | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
r1: Hacl.K256.Scalar.qelem ->
r2: Hacl.K256.Scalar.qelem ->
q1: Hacl.Impl.K256.Point.point ->
q2: Hacl.Impl.K256.Point.point ->
scalar: Hacl.K256.Scalar.qelem ->
q: Hacl.Impl.K256.Point.point
-> FStar.HyperStack.ST.Stack (Prims.bool * Prims.bool) | {
"end_col": 20,
"end_line": 269,
"start_col": 44,
"start_line": 260
} |
FStar.HyperStack.ST.Stack | val point_mul_lambda: res:point -> p:point -> Stack unit
(requires fun h ->
live h res /\ live h p /\ eq_or_disjoint res p /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
point_eval h1 res == SG.point_mul_lambda (point_eval h0 p)) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let point_mul_lambda res p =
push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let px, py, pz = getx p, gety p, getz p in
let beta = create_felem () in
make_beta beta;
fmul rx beta px;
copy_felem ry py;
copy_felem rz pz;
pop_frame () | val point_mul_lambda: res:point -> p:point -> Stack unit
(requires fun h ->
live h res /\ live h p /\ eq_or_disjoint res p /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
point_eval h1 res == SG.point_mul_lambda (point_eval h0 p))
let point_mul_lambda res p = | true | null | false | push_frame ();
let rx, ry, rz = getx res, gety res, getz res in
let px, py, pz = getx p, gety p, getz p in
let beta = create_felem () in
make_beta beta;
fmul rx beta px;
copy_felem ry py;
copy_felem rz pz;
pop_frame () | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.Impl.K256.Point.point",
"Hacl.K256.Field.felem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.K256.Field.copy_felem",
"Hacl.K256.Field.fmul",
"Hacl.Impl.K256.GLV.Constants.make_beta",
"Hacl.K256.Field.create_felem",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"Hacl.Impl.K256.Point.getz",
"Hacl.Impl.K256.Point.gety",
"Hacl.Impl.K256.Point.getx",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1)
let make_g1 f =
[@inline_let]
let x =
(u64 0xe893209a45dbb031,
u64 0x3daa8a1471e8ca7f,
u64 0xe86c90e49284eb15,
u64 0x3086d221a7d46bcd) in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2)
let make_g2 f =
[@inline_let]
let x =
(u64 0x1571b4ae8ac47f71,
u64 0x221208ac9df506c6,
u64 0x6f547fa90abfe4c4,
u64 0xe4437ed6010e8828) in
assert_norm (SG.g2 == qas_nat4 x);
make_u64_4 f x
(**
Representing a scalar k as (r1 + r2 * lambda) mod S.q,
s.t. r1 and r2 are ~128 bits long
*)
inline_for_extraction noextract
val scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2))
let scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k =
make_g1 tmp1; // tmp1 = g1
make_g2 tmp2; // tmp2 = g2
qmul_shift_384 r1 k tmp1; // r1 = c1 = qmul_shift_384 k g1
qmul_shift_384 r2 k tmp2; // r2 = c2 = qmul_shift_384 k g2
let h0 = ST.get () in
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp1);
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp2);
assert (qas_nat h0 r1 < S.q /\ qas_nat h0 r2 < S.q)
// k = (r1 + lambda * k2) % S.q
val scalar_split_lambda (r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
qas_nat h k < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2) h0 h1 /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 k) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
[@CInline]
let scalar_split_lambda r1 r2 k =
push_frame ();
let tmp1 = create_qelem () in
let tmp2 = create_qelem () in
scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k;
make_minus_b1 tmp1; // tmp1 = minus_b1
make_minus_b2 tmp2; // tmp2 = minus_b2
qmul r1 r1 tmp1; // r1 = c1 = c1 * minus_b1
qmul r2 r2 tmp2; // r2 = c2 = c2 * minus_b2
make_minus_lambda tmp1; // tmp1 = minus_lambda
qadd r2 r1 r2; // r2 = r2 = c1 + c2
qmul tmp2 r2 tmp1; // tmp2 = r2 * minus_lambda
qadd r1 k tmp2; // r1 = r1 = k + r2 * minus_lambda
pop_frame ()
(**
Fast computation of [lambda]P as (beta * px, py, pz) in projective coordinates
*)
[@CInline] | false | false | Hacl.Impl.K256.GLV.Constants.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val point_mul_lambda: res:point -> p:point -> Stack unit
(requires fun h ->
live h res /\ live h p /\ eq_or_disjoint res p /\
point_inv h p)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
point_inv h1 res /\
point_eval h1 res == SG.point_mul_lambda (point_eval h0 p)) | [] | Hacl.Impl.K256.GLV.Constants.point_mul_lambda | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | res: Hacl.Impl.K256.Point.point -> p: Hacl.Impl.K256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 208,
"start_col": 2,
"start_line": 199
} |
FStar.HyperStack.ST.Stack | val scalar_split_lambda (r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
qas_nat h k < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2) h0 h1 /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 k) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s)) | [
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV.Lemmas",
"short_module": "SGL"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Scalar",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.K256.Field",
"short_module": null
},
{
"abbrev": true,
"full_module": "Hacl.Spec.K256.GLV",
"short_module": "SG"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.K256.GLV",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let scalar_split_lambda r1 r2 k =
push_frame ();
let tmp1 = create_qelem () in
let tmp2 = create_qelem () in
scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k;
make_minus_b1 tmp1; // tmp1 = minus_b1
make_minus_b2 tmp2; // tmp2 = minus_b2
qmul r1 r1 tmp1; // r1 = c1 = c1 * minus_b1
qmul r2 r2 tmp2; // r2 = c2 = c2 * minus_b2
make_minus_lambda tmp1; // tmp1 = minus_lambda
qadd r2 r1 r2; // r2 = r2 = c1 + c2
qmul tmp2 r2 tmp1; // tmp2 = r2 * minus_lambda
qadd r1 k tmp2; // r1 = r1 = k + r2 * minus_lambda
pop_frame () | val scalar_split_lambda (r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
qas_nat h k < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2) h0 h1 /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 k) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
let scalar_split_lambda r1 r2 k = | true | null | false | push_frame ();
let tmp1 = create_qelem () in
let tmp2 = create_qelem () in
scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k;
make_minus_b1 tmp1;
make_minus_b2 tmp2;
qmul r1 r1 tmp1;
qmul r2 r2 tmp2;
make_minus_lambda tmp1;
qadd r2 r1 r2;
qmul tmp2 r2 tmp1;
qadd r1 k tmp2;
pop_frame () | {
"checked_file": "Hacl.Impl.K256.GLV.Constants.fst.checked",
"dependencies": [
"Spec.K256.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.K256.GLV.Lemmas.fst.checked",
"Hacl.Spec.K256.GLV.fst.checked",
"Hacl.K256.Scalar.fsti.checked",
"Hacl.K256.Field.fsti.checked",
"Hacl.Impl.K256.Point.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": true,
"source_file": "Hacl.Impl.K256.GLV.Constants.fst"
} | [] | [
"Hacl.K256.Scalar.qelem",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.K256.Scalar.qadd",
"Hacl.K256.Scalar.qmul",
"Hacl.Impl.K256.GLV.Constants.make_minus_lambda",
"Hacl.Impl.K256.GLV.Constants.make_minus_b2",
"Hacl.Impl.K256.GLV.Constants.make_minus_b1",
"Hacl.Impl.K256.GLV.Constants.scalar_split_lambda_g1g2",
"Hacl.K256.Scalar.create_qelem",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.K256.GLV.Constants
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
module ST = FStar.HyperStack.ST
module S = Spec.K256
module SG = Hacl.Spec.K256.GLV
module SGL = Hacl.Spec.K256.GLV.Lemmas
open Hacl.K256.Field
open Hacl.K256.Scalar
open Hacl.Impl.K256.Point
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val make_minus_lambda: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_lambda)
let make_minus_lambda f =
[@inline_let]
let x =
(u64 0xe0cfc810b51283cf,
u64 0xa880b9fc8ec739c2,
u64 0x5ad9e3fd77ed9ba4,
u64 0xac9c52b33fa3cf1f) in
assert_norm (SG.minus_lambda == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_beta: f:felem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
as_nat h1 f == SG.beta /\ inv_fully_reduced h1 f)
let make_beta f =
[@inline_let]
let x =
(u64 0x96c28719501ee,
u64 0x7512f58995c13,
u64 0xc3434e99cf049,
u64 0x7106e64479ea,
u64 0x7ae96a2b657c) in
assert_norm (0x96c28719501ee <= max52);
assert_norm (0x7ae96a2b657c <= max48);
assert_norm (SG.beta == as_nat5 x);
make_u52_5 f x
inline_for_extraction noextract
val make_minus_b1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b1)
let make_minus_b1 f =
[@inline_let]
let x =
(u64 0x6f547fa90abfe4c3,
u64 0xe4437ed6010e8828,
u64 0x0,
u64 0x0) in
assert_norm (SG.minus_b1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_minus_b2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.minus_b2)
let make_minus_b2 f =
[@inline_let]
let x =
(u64 0xd765cda83db1562c,
u64 0x8a280ac50774346d,
u64 0xfffffffffffffffe,
u64 0xffffffffffffffff) in
assert_norm (SG.minus_b2 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g1: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g1)
let make_g1 f =
[@inline_let]
let x =
(u64 0xe893209a45dbb031,
u64 0x3daa8a1471e8ca7f,
u64 0xe86c90e49284eb15,
u64 0x3086d221a7d46bcd) in
assert_norm (SG.g1 == qas_nat4 x);
make_u64_4 f x
inline_for_extraction noextract
val make_g2: f:qelem -> Stack unit
(requires fun h -> live h f)
(ensures fun h0 _ h1 -> modifies (loc f) h0 h1 /\
qas_nat h1 f == SG.g2)
let make_g2 f =
[@inline_let]
let x =
(u64 0x1571b4ae8ac47f71,
u64 0x221208ac9df506c6,
u64 0x6f547fa90abfe4c4,
u64 0xe4437ed6010e8828) in
assert_norm (SG.g2 == qas_nat4 x);
make_u64_4 f x
(**
Representing a scalar k as (r1 + r2 * lambda) mod S.q,
s.t. r1 and r2 are ~128 bits long
*)
inline_for_extraction noextract
val scalar_split_lambda_g1g2 (tmp1 tmp2 r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
live h tmp1 /\ live h tmp2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
disjoint tmp1 r1 /\ disjoint tmp1 r2 /\ disjoint tmp1 k /\
disjoint tmp2 r1 /\ disjoint tmp2 r2 /\ disjoint tmp2 k /\
disjoint tmp1 tmp2 /\ qas_nat h k < S.q)
(ensures fun h0 _ h1 ->
modifies (loc r1 |+| loc r2 |+| loc tmp1 |+| loc tmp2) h0 h1 /\
(let r1 = qas_nat h1 r1 in let r2 = qas_nat h1 r2 in
r1 < S.q /\ r1 = SG.qmul_shift_384 (qas_nat h0 k) SG.g1 /\
r2 < S.q /\ r2 = SG.qmul_shift_384 (qas_nat h0 k) SG.g2))
let scalar_split_lambda_g1g2 tmp1 tmp2 r1 r2 k =
make_g1 tmp1; // tmp1 = g1
make_g2 tmp2; // tmp2 = g2
qmul_shift_384 r1 k tmp1; // r1 = c1 = qmul_shift_384 k g1
qmul_shift_384 r2 k tmp2; // r2 = c2 = qmul_shift_384 k g2
let h0 = ST.get () in
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp1);
SG.qmul_shift_384_lemma (qas_nat h0 k) (qas_nat h0 tmp2);
assert (qas_nat h0 r1 < S.q /\ qas_nat h0 r2 < S.q)
// k = (r1 + lambda * k2) % S.q
val scalar_split_lambda (r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
qas_nat h k < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2) h0 h1 /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 k) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s))
[@CInline] | false | false | Hacl.Impl.K256.GLV.Constants.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 scalar_split_lambda (r1 r2 k: qelem) : Stack unit
(requires fun h ->
live h k /\ live h r1 /\ live h r2 /\
disjoint k r1 /\ disjoint k r2 /\ disjoint r1 r2 /\
qas_nat h k < S.q)
(ensures fun h0 _ h1 -> modifies (loc r1 |+| loc r2) h0 h1 /\
(let r1_s, r2_s = SG.scalar_split_lambda (qas_nat h0 k) in
qas_nat h1 r1 == r1_s /\ qas_nat h1 r2 == r2_s)) | [] | Hacl.Impl.K256.GLV.Constants.scalar_split_lambda | {
"file_name": "code/k256/Hacl.Impl.K256.GLV.Constants.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | r1: Hacl.K256.Scalar.qelem -> r2: Hacl.K256.Scalar.qelem -> k: Hacl.K256.Scalar.qelem
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 14,
"end_line": 190,
"start_col": 2,
"start_line": 176
} |
Prims.Tot | val prot:Type u#1 | [
{
"abbrev": false,
"full_module": "Steel.Effect",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Channel.Protocol",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Channel",
"short_module": null
},
{
"abbrev": false,
"full_module": "Steel.Channel",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let prot : Type u#1 = protocol unit | val prot:Type u#1
let prot:Type u#1 = | false | null | false | protocol unit | {
"checked_file": "Steel.Channel.Duplex.fsti.checked",
"dependencies": [
"Steel.Memory.fsti.checked",
"Steel.Effect.fsti.checked",
"Steel.Channel.Protocol.fst.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Duplex.fsti"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit"
] | [] | (*
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 Steel.Channel.Duplex
open Steel.Channel.Protocol
open Steel.Memory
open Steel.Effect
/// This library provides a model of two-party session types in Steel.
/// Protocols are specified using the structure in Steel.Channel.Protocol
/// Channels are indexed by a given protocols, and ensure that any message exchanged
/// on the channel respect the protocol.
/// An implementation of this model is currently available in Duplex.PCM.fst
/// Msg int (fun x -> Msg (y:int { y > x }) (fun _ -> Ret unit))
/// | false | true | Steel.Channel.Duplex.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val prot:Type u#1 | [] | Steel.Channel.Duplex.prot | {
"file_name": "lib/steel/Steel.Channel.Duplex.fsti",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Type | {
"end_col": 35,
"end_line": 31,
"start_col": 22,
"start_line": 31
} |
Prims.Tot | val is_gctr_plain (p: seq nat8) : prop0 | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_gctr_plain (p:seq nat8) : prop0 = length p < pow2_32 | val is_gctr_plain (p: seq nat8) : prop0
let is_gctr_plain (p: seq nat8) : prop0 = | false | null | false | length p < pow2_32 | {
"checked_file": "Vale.AES.GCTR_BE_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_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.GCTR_BE_s.fst"
} | [
"total"
] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.Def.Words_s.pow2_32",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.AES.GCTR_BE_s
// IMPORTANT: Following NIST's specification, this spec is written assuming a big-endian mapping from bytes to quad32s
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Mul
open Vale.AES.AES_BE_s
open FStar.Seq
// The max length of pow2_32 corresponds to the max length of buffers in Low* | false | true | Vale.AES.GCTR_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_gctr_plain (p: seq nat8) : prop0 | [] | Vale.AES.GCTR_BE_s.is_gctr_plain | {
"file_name": "vale/specs/crypto/Vale.AES.GCTR_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> Vale.Def.Prop_s.prop0 | {
"end_col": 59,
"end_line": 17,
"start_col": 41,
"start_line": 17
} |
Prims.Pure | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr_encrypt = opaque_make gctr_encrypt_def | let gctr_encrypt = | false | null | false | opaque_make gctr_encrypt_def | {
"checked_file": "Vale.AES.GCTR_BE_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_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.GCTR_BE_s.fst"
} | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.AES_common_s.algorithm",
"Vale.Def.Types_s.nat32",
"Prims.l_and",
"Vale.AES.GCTR_BE_s.is_gctr_plain",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Prims.l_True",
"Vale.AES.GCTR_BE_s.gctr_encrypt_def"
] | [] | module Vale.AES.GCTR_BE_s
// IMPORTANT: Following NIST's specification, this spec is written assuming a big-endian mapping from bytes to quad32s
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Mul
open Vale.AES.AES_BE_s
open FStar.Seq
// The max length of pow2_32 corresponds to the max length of buffers in Low*
// length plain < pow2_32 <= spec max of 2**39 - 256;
let is_gctr_plain (p:seq nat8) : prop0 = length p < pow2_32
type gctr_plain:eqtype = p:seq nat8 { is_gctr_plain p }
type gctr_plain_internal:eqtype = seq quad32
let inc32 (cb:quad32) (i:int) : quad32 =
Mkfour ((cb.lo0 + i) % pow2_32) cb.lo1 cb.hi2 cb.hi3
let gctr_encrypt_block (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) : Pure quad32
(requires is_aes_key_word alg key)
(ensures fun _ -> True)
=
quad32_xor plain (aes_encrypt_word alg key (inc32 icb i))
let rec gctr_encrypt_recursive (icb:quad32) (plain:gctr_plain_internal)
(alg:algorithm) (key:aes_key_word alg) (i:int) : Tot (seq quad32) (decreases %[length plain]) =
if length plain = 0 then empty
else
cons (gctr_encrypt_block icb (head plain) alg key i) (gctr_encrypt_recursive icb (tail plain) alg key (i + 1))
let pad_to_128_bits (p:seq nat8) : Pure (seq nat8)
(requires True)
(ensures fun q -> length q % 16 == 0 /\ length q <= length p + 15)
=
let num_extra_bytes = length p % 16 in
if num_extra_bytes = 0 then p
else p @| (create (16 - num_extra_bytes) 0)
let gctr_encrypt_def (icb:quad32) (plain:seq nat8) (alg:algorithm) (key:seq nat32) : Pure (seq nat8)
(requires is_gctr_plain plain /\ is_aes_key_word alg key)
(ensures fun _ -> True)
=
let num_extra = (length plain) % 16 in
if num_extra = 0 then
let plain_quads = be_bytes_to_seq_quad32 plain in
let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in
seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads)
else
let full_bytes_len = (length plain) - num_extra in
let full_blocks, final_block = split plain full_bytes_len in
let full_quads = be_bytes_to_seq_quad32 full_blocks in
let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in
let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in
let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in
let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in
let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in | false | false | Vale.AES.GCTR_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr_encrypt : icb: Vale.Def.Types_s.quad32 ->
plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8) | [] | Vale.AES.GCTR_BE_s.gctr_encrypt | {
"file_name": "vale/specs/crypto/Vale.AES.GCTR_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
icb: Vale.Def.Types_s.quad32 ->
plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8) | {
"end_col": 67,
"end_line": 69,
"start_col": 39,
"start_line": 69
} |
|
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr_encrypt_reveal = opaque_revealer (`%gctr_encrypt) gctr_encrypt gctr_encrypt_def | let gctr_encrypt_reveal = | false | null | true | opaque_revealer (`%gctr_encrypt) gctr_encrypt gctr_encrypt_def | {
"checked_file": "Vale.AES.GCTR_BE_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_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.GCTR_BE_s.fst"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.AES_common_s.algorithm",
"Vale.Def.Types_s.nat32",
"Prims.l_and",
"Vale.AES.GCTR_BE_s.is_gctr_plain",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Prims.l_True",
"Vale.AES.GCTR_BE_s.gctr_encrypt",
"Vale.AES.GCTR_BE_s.gctr_encrypt_def"
] | [] | module Vale.AES.GCTR_BE_s
// IMPORTANT: Following NIST's specification, this spec is written assuming a big-endian mapping from bytes to quad32s
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Mul
open Vale.AES.AES_BE_s
open FStar.Seq
// The max length of pow2_32 corresponds to the max length of buffers in Low*
// length plain < pow2_32 <= spec max of 2**39 - 256;
let is_gctr_plain (p:seq nat8) : prop0 = length p < pow2_32
type gctr_plain:eqtype = p:seq nat8 { is_gctr_plain p }
type gctr_plain_internal:eqtype = seq quad32
let inc32 (cb:quad32) (i:int) : quad32 =
Mkfour ((cb.lo0 + i) % pow2_32) cb.lo1 cb.hi2 cb.hi3
let gctr_encrypt_block (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) : Pure quad32
(requires is_aes_key_word alg key)
(ensures fun _ -> True)
=
quad32_xor plain (aes_encrypt_word alg key (inc32 icb i))
let rec gctr_encrypt_recursive (icb:quad32) (plain:gctr_plain_internal)
(alg:algorithm) (key:aes_key_word alg) (i:int) : Tot (seq quad32) (decreases %[length plain]) =
if length plain = 0 then empty
else
cons (gctr_encrypt_block icb (head plain) alg key i) (gctr_encrypt_recursive icb (tail plain) alg key (i + 1))
let pad_to_128_bits (p:seq nat8) : Pure (seq nat8)
(requires True)
(ensures fun q -> length q % 16 == 0 /\ length q <= length p + 15)
=
let num_extra_bytes = length p % 16 in
if num_extra_bytes = 0 then p
else p @| (create (16 - num_extra_bytes) 0)
let gctr_encrypt_def (icb:quad32) (plain:seq nat8) (alg:algorithm) (key:seq nat32) : Pure (seq nat8)
(requires is_gctr_plain plain /\ is_aes_key_word alg key)
(ensures fun _ -> True)
=
let num_extra = (length plain) % 16 in
if num_extra = 0 then
let plain_quads = be_bytes_to_seq_quad32 plain in
let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in
seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads)
else
let full_bytes_len = (length plain) - num_extra in
let full_blocks, final_block = split plain full_bytes_len in
let full_quads = be_bytes_to_seq_quad32 full_blocks in
let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in
let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in
let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in
let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in
let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in
cipher_bytes_full @| final_cipher_bytes | false | false | Vale.AES.GCTR_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr_encrypt_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCTR_BE_s.gctr_encrypt == Vale.AES.GCTR_BE_s.gctr_encrypt_def) | [] | Vale.AES.GCTR_BE_s.gctr_encrypt_reveal | {
"file_name": "vale/specs/crypto/Vale.AES.GCTR_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.GCTR_BE_s.gctr_encrypt == Vale.AES.GCTR_BE_s.gctr_encrypt_def) | {
"end_col": 100,
"end_line": 70,
"start_col": 38,
"start_line": 70
} |
|
Prims.Tot | val inc32 (cb: quad32) (i: int) : quad32 | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let inc32 (cb:quad32) (i:int) : quad32 =
Mkfour ((cb.lo0 + i) % pow2_32) cb.lo1 cb.hi2 cb.hi3 | val inc32 (cb: quad32) (i: int) : quad32
let inc32 (cb: quad32) (i: int) : quad32 = | false | null | false | Mkfour ((cb.lo0 + i) % pow2_32) cb.lo1 cb.hi2 cb.hi3 | {
"checked_file": "Vale.AES.GCTR_BE_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_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.GCTR_BE_s.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Prims.int",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Prims.op_Modulus",
"Prims.op_Addition",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.pow2_32",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3"
] | [] | module Vale.AES.GCTR_BE_s
// IMPORTANT: Following NIST's specification, this spec is written assuming a big-endian mapping from bytes to quad32s
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Mul
open Vale.AES.AES_BE_s
open FStar.Seq
// The max length of pow2_32 corresponds to the max length of buffers in Low*
// length plain < pow2_32 <= spec max of 2**39 - 256;
let is_gctr_plain (p:seq nat8) : prop0 = length p < pow2_32
type gctr_plain:eqtype = p:seq nat8 { is_gctr_plain p }
type gctr_plain_internal:eqtype = seq quad32 | false | true | Vale.AES.GCTR_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val inc32 (cb: quad32) (i: int) : quad32 | [] | Vale.AES.GCTR_BE_s.inc32 | {
"file_name": "vale/specs/crypto/Vale.AES.GCTR_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | cb: Vale.Def.Types_s.quad32 -> i: Prims.int -> Vale.Def.Types_s.quad32 | {
"end_col": 54,
"end_line": 22,
"start_col": 2,
"start_line": 22
} |
Prims.Pure | val gctr_encrypt_block (icb plain: quad32) (alg: algorithm) (key: seq nat32) (i: int)
: Pure quad32 (requires is_aes_key_word alg key) (ensures fun _ -> True) | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr_encrypt_block (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) : Pure quad32
(requires is_aes_key_word alg key)
(ensures fun _ -> True)
=
quad32_xor plain (aes_encrypt_word alg key (inc32 icb i)) | val gctr_encrypt_block (icb plain: quad32) (alg: algorithm) (key: seq nat32) (i: int)
: Pure quad32 (requires is_aes_key_word alg key) (ensures fun _ -> True)
let gctr_encrypt_block (icb plain: quad32) (alg: algorithm) (key: seq nat32) (i: int)
: Pure quad32 (requires is_aes_key_word alg key) (ensures fun _ -> True) = | false | null | false | quad32_xor plain (aes_encrypt_word alg key (inc32 icb i)) | {
"checked_file": "Vale.AES.GCTR_BE_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_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.GCTR_BE_s.fst"
} | [] | [
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.int",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_BE_s.aes_encrypt_word",
"Vale.AES.GCTR_BE_s.inc32",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Prims.l_True"
] | [] | module Vale.AES.GCTR_BE_s
// IMPORTANT: Following NIST's specification, this spec is written assuming a big-endian mapping from bytes to quad32s
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Mul
open Vale.AES.AES_BE_s
open FStar.Seq
// The max length of pow2_32 corresponds to the max length of buffers in Low*
// length plain < pow2_32 <= spec max of 2**39 - 256;
let is_gctr_plain (p:seq nat8) : prop0 = length p < pow2_32
type gctr_plain:eqtype = p:seq nat8 { is_gctr_plain p }
type gctr_plain_internal:eqtype = seq quad32
let inc32 (cb:quad32) (i:int) : quad32 =
Mkfour ((cb.lo0 + i) % pow2_32) cb.lo1 cb.hi2 cb.hi3
let gctr_encrypt_block (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) : Pure quad32
(requires is_aes_key_word alg key)
(ensures fun _ -> True) | false | false | Vale.AES.GCTR_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr_encrypt_block (icb plain: quad32) (alg: algorithm) (key: seq nat32) (i: int)
: Pure quad32 (requires is_aes_key_word alg key) (ensures fun _ -> True) | [] | Vale.AES.GCTR_BE_s.gctr_encrypt_block | {
"file_name": "vale/specs/crypto/Vale.AES.GCTR_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
icb: Vale.Def.Types_s.quad32 ->
plain: Vale.Def.Types_s.quad32 ->
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 ->
i: Prims.int
-> Prims.Pure Vale.Def.Types_s.quad32 | {
"end_col": 59,
"end_line": 28,
"start_col": 2,
"start_line": 28
} |
Prims.Pure | val pad_to_128_bits (p: seq nat8)
: Pure (seq nat8)
(requires True)
(ensures fun q -> length q % 16 == 0 /\ length q <= length p + 15) | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let pad_to_128_bits (p:seq nat8) : Pure (seq nat8)
(requires True)
(ensures fun q -> length q % 16 == 0 /\ length q <= length p + 15)
=
let num_extra_bytes = length p % 16 in
if num_extra_bytes = 0 then p
else p @| (create (16 - num_extra_bytes) 0) | val pad_to_128_bits (p: seq nat8)
: Pure (seq nat8)
(requires True)
(ensures fun q -> length q % 16 == 0 /\ length q <= length p + 15)
let pad_to_128_bits (p: seq nat8)
: Pure (seq nat8)
(requires True)
(ensures fun q -> length q % 16 == 0 /\ length q <= length p + 15) = | false | null | false | let num_extra_bytes = length p % 16 in
if num_extra_bytes = 0 then p else p @| (create (16 - num_extra_bytes) 0) | {
"checked_file": "Vale.AES.GCTR_BE_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_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.GCTR_BE_s.fst"
} | [] | [
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"FStar.Seq.Base.op_At_Bar",
"FStar.Seq.Base.create",
"Prims.op_Subtraction",
"Prims.op_Modulus",
"FStar.Seq.Base.length",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition"
] | [] | module Vale.AES.GCTR_BE_s
// IMPORTANT: Following NIST's specification, this spec is written assuming a big-endian mapping from bytes to quad32s
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Mul
open Vale.AES.AES_BE_s
open FStar.Seq
// The max length of pow2_32 corresponds to the max length of buffers in Low*
// length plain < pow2_32 <= spec max of 2**39 - 256;
let is_gctr_plain (p:seq nat8) : prop0 = length p < pow2_32
type gctr_plain:eqtype = p:seq nat8 { is_gctr_plain p }
type gctr_plain_internal:eqtype = seq quad32
let inc32 (cb:quad32) (i:int) : quad32 =
Mkfour ((cb.lo0 + i) % pow2_32) cb.lo1 cb.hi2 cb.hi3
let gctr_encrypt_block (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) : Pure quad32
(requires is_aes_key_word alg key)
(ensures fun _ -> True)
=
quad32_xor plain (aes_encrypt_word alg key (inc32 icb i))
let rec gctr_encrypt_recursive (icb:quad32) (plain:gctr_plain_internal)
(alg:algorithm) (key:aes_key_word alg) (i:int) : Tot (seq quad32) (decreases %[length plain]) =
if length plain = 0 then empty
else
cons (gctr_encrypt_block icb (head plain) alg key i) (gctr_encrypt_recursive icb (tail plain) alg key (i + 1))
let pad_to_128_bits (p:seq nat8) : Pure (seq nat8)
(requires True) | false | false | Vale.AES.GCTR_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val pad_to_128_bits (p: seq nat8)
: Pure (seq nat8)
(requires True)
(ensures fun q -> length q % 16 == 0 /\ length q <= length p + 15) | [] | Vale.AES.GCTR_BE_s.pad_to_128_bits | {
"file_name": "vale/specs/crypto/Vale.AES.GCTR_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 -> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8) | {
"end_col": 45,
"end_line": 43,
"start_col": 3,
"start_line": 40
} |
Prims.Tot | val gctr_encrypt_recursive
(icb: quad32)
(plain: gctr_plain_internal)
(alg: algorithm)
(key: aes_key_word alg)
(i: int)
: Tot (seq quad32) (decreases %[length plain]) | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rec gctr_encrypt_recursive (icb:quad32) (plain:gctr_plain_internal)
(alg:algorithm) (key:aes_key_word alg) (i:int) : Tot (seq quad32) (decreases %[length plain]) =
if length plain = 0 then empty
else
cons (gctr_encrypt_block icb (head plain) alg key i) (gctr_encrypt_recursive icb (tail plain) alg key (i + 1)) | val gctr_encrypt_recursive
(icb: quad32)
(plain: gctr_plain_internal)
(alg: algorithm)
(key: aes_key_word alg)
(i: int)
: Tot (seq quad32) (decreases %[length plain])
let rec gctr_encrypt_recursive
(icb: quad32)
(plain: gctr_plain_internal)
(alg: algorithm)
(key: aes_key_word alg)
(i: int)
: Tot (seq quad32) (decreases %[length plain]) = | false | null | false | if length plain = 0
then empty
else
cons (gctr_encrypt_block icb (head plain) alg key i)
(gctr_encrypt_recursive icb (tail plain) alg key (i + 1)) | {
"checked_file": "Vale.AES.GCTR_BE_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_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.GCTR_BE_s.fst"
} | [
"total",
""
] | [
"Vale.Def.Types_s.quad32",
"Vale.AES.GCTR_BE_s.gctr_plain_internal",
"Vale.AES.AES_common_s.algorithm",
"Vale.AES.AES_BE_s.aes_key_word",
"Prims.int",
"Prims.op_Equality",
"FStar.Seq.Base.length",
"FStar.Seq.Base.empty",
"Prims.bool",
"FStar.Seq.Properties.cons",
"Vale.AES.GCTR_BE_s.gctr_encrypt_block",
"FStar.Seq.Properties.head",
"Vale.AES.GCTR_BE_s.gctr_encrypt_recursive",
"FStar.Seq.Properties.tail",
"Prims.op_Addition",
"FStar.Seq.Base.seq"
] | [] | module Vale.AES.GCTR_BE_s
// IMPORTANT: Following NIST's specification, this spec is written assuming a big-endian mapping from bytes to quad32s
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Mul
open Vale.AES.AES_BE_s
open FStar.Seq
// The max length of pow2_32 corresponds to the max length of buffers in Low*
// length plain < pow2_32 <= spec max of 2**39 - 256;
let is_gctr_plain (p:seq nat8) : prop0 = length p < pow2_32
type gctr_plain:eqtype = p:seq nat8 { is_gctr_plain p }
type gctr_plain_internal:eqtype = seq quad32
let inc32 (cb:quad32) (i:int) : quad32 =
Mkfour ((cb.lo0 + i) % pow2_32) cb.lo1 cb.hi2 cb.hi3
let gctr_encrypt_block (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) : Pure quad32
(requires is_aes_key_word alg key)
(ensures fun _ -> True)
=
quad32_xor plain (aes_encrypt_word alg key (inc32 icb i))
let rec gctr_encrypt_recursive (icb:quad32) (plain:gctr_plain_internal) | false | false | Vale.AES.GCTR_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr_encrypt_recursive
(icb: quad32)
(plain: gctr_plain_internal)
(alg: algorithm)
(key: aes_key_word alg)
(i: int)
: Tot (seq quad32) (decreases %[length plain]) | [
"recursion"
] | Vale.AES.GCTR_BE_s.gctr_encrypt_recursive | {
"file_name": "vale/specs/crypto/Vale.AES.GCTR_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
icb: Vale.Def.Types_s.quad32 ->
plain: Vale.AES.GCTR_BE_s.gctr_plain_internal ->
alg: Vale.AES.AES_common_s.algorithm ->
key: Vale.AES.AES_BE_s.aes_key_word alg ->
i: Prims.int
-> Prims.Tot (FStar.Seq.Base.seq Vale.Def.Types_s.quad32) | {
"end_col": 114,
"end_line": 35,
"start_col": 2,
"start_line": 33
} |
Prims.Pure | val gctr_encrypt_def (icb: quad32) (plain: seq nat8) (alg: algorithm) (key: seq nat32)
: Pure (seq nat8)
(requires is_gctr_plain plain /\ is_aes_key_word alg key)
(ensures fun _ -> True) | [
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gctr_encrypt_def (icb:quad32) (plain:seq nat8) (alg:algorithm) (key:seq nat32) : Pure (seq nat8)
(requires is_gctr_plain plain /\ is_aes_key_word alg key)
(ensures fun _ -> True)
=
let num_extra = (length plain) % 16 in
if num_extra = 0 then
let plain_quads = be_bytes_to_seq_quad32 plain in
let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in
seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads)
else
let full_bytes_len = (length plain) - num_extra in
let full_blocks, final_block = split plain full_bytes_len in
let full_quads = be_bytes_to_seq_quad32 full_blocks in
let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in
let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in
let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in
let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in
let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in
cipher_bytes_full @| final_cipher_bytes | val gctr_encrypt_def (icb: quad32) (plain: seq nat8) (alg: algorithm) (key: seq nat32)
: Pure (seq nat8)
(requires is_gctr_plain plain /\ is_aes_key_word alg key)
(ensures fun _ -> True)
let gctr_encrypt_def (icb: quad32) (plain: seq nat8) (alg: algorithm) (key: seq nat32)
: Pure (seq nat8)
(requires is_gctr_plain plain /\ is_aes_key_word alg key)
(ensures fun _ -> True) = | false | null | false | let num_extra = (length plain) % 16 in
if num_extra = 0
then
let plain_quads = be_bytes_to_seq_quad32 plain in
let cipher_quads = gctr_encrypt_recursive icb plain_quads alg key 0 in
seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads)
else
let full_bytes_len = (length plain) - num_extra in
let full_blocks, final_block = split plain full_bytes_len in
let full_quads = be_bytes_to_seq_quad32 full_blocks in
let final_quad = be_bytes_to_quad32 (pad_to_128_bits final_block) in
let cipher_quads = gctr_encrypt_recursive icb full_quads alg key 0 in
let final_cipher_quad = gctr_encrypt_block icb final_quad alg key (full_bytes_len / 16) in
let cipher_bytes_full = seq_nat32_to_seq_nat8_BE (seq_four_to_seq_BE cipher_quads) in
let final_cipher_bytes = slice (be_quad32_to_bytes final_cipher_quad) 0 num_extra in
cipher_bytes_full @| final_cipher_bytes | {
"checked_file": "Vale.AES.GCTR_BE_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.AES_BE_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.GCTR_BE_s.fst"
} | [] | [
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat8",
"Vale.AES.AES_common_s.algorithm",
"Vale.Def.Types_s.nat32",
"Prims.op_Equality",
"Prims.int",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_BE",
"Vale.Def.Words.Seq_s.seq_four_to_seq_BE",
"Vale.AES.GCTR_BE_s.gctr_encrypt_recursive",
"Vale.Def.Types_s.be_bytes_to_seq_quad32",
"Prims.bool",
"FStar.Seq.Base.op_At_Bar",
"Vale.Def.Words_s.nat8",
"FStar.Seq.Base.slice",
"Vale.Arch.Types.be_quad32_to_bytes",
"Vale.AES.GCTR_BE_s.gctr_encrypt_block",
"Prims.op_Division",
"Vale.Def.Types_s.be_bytes_to_quad32",
"Vale.AES.GCTR_BE_s.pad_to_128_bits",
"FStar.Pervasives.Native.tuple2",
"FStar.Seq.Properties.split",
"Prims.op_Subtraction",
"FStar.Seq.Base.length",
"Prims.op_Modulus",
"Prims.l_and",
"Vale.AES.GCTR_BE_s.is_gctr_plain",
"Vale.AES.AES_BE_s.is_aes_key_word",
"Prims.l_True"
] | [] | module Vale.AES.GCTR_BE_s
// IMPORTANT: Following NIST's specification, this spec is written assuming a big-endian mapping from bytes to quad32s
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Mul
open Vale.AES.AES_BE_s
open FStar.Seq
// The max length of pow2_32 corresponds to the max length of buffers in Low*
// length plain < pow2_32 <= spec max of 2**39 - 256;
let is_gctr_plain (p:seq nat8) : prop0 = length p < pow2_32
type gctr_plain:eqtype = p:seq nat8 { is_gctr_plain p }
type gctr_plain_internal:eqtype = seq quad32
let inc32 (cb:quad32) (i:int) : quad32 =
Mkfour ((cb.lo0 + i) % pow2_32) cb.lo1 cb.hi2 cb.hi3
let gctr_encrypt_block (icb:quad32) (plain:quad32) (alg:algorithm) (key:seq nat32) (i:int) : Pure quad32
(requires is_aes_key_word alg key)
(ensures fun _ -> True)
=
quad32_xor plain (aes_encrypt_word alg key (inc32 icb i))
let rec gctr_encrypt_recursive (icb:quad32) (plain:gctr_plain_internal)
(alg:algorithm) (key:aes_key_word alg) (i:int) : Tot (seq quad32) (decreases %[length plain]) =
if length plain = 0 then empty
else
cons (gctr_encrypt_block icb (head plain) alg key i) (gctr_encrypt_recursive icb (tail plain) alg key (i + 1))
let pad_to_128_bits (p:seq nat8) : Pure (seq nat8)
(requires True)
(ensures fun q -> length q % 16 == 0 /\ length q <= length p + 15)
=
let num_extra_bytes = length p % 16 in
if num_extra_bytes = 0 then p
else p @| (create (16 - num_extra_bytes) 0)
let gctr_encrypt_def (icb:quad32) (plain:seq nat8) (alg:algorithm) (key:seq nat32) : Pure (seq nat8)
(requires is_gctr_plain plain /\ is_aes_key_word alg key) | false | false | Vale.AES.GCTR_BE_s.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 0,
"max_fuel": 1,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gctr_encrypt_def (icb: quad32) (plain: seq nat8) (alg: algorithm) (key: seq nat32)
: Pure (seq nat8)
(requires is_gctr_plain plain /\ is_aes_key_word alg key)
(ensures fun _ -> True) | [] | Vale.AES.GCTR_BE_s.gctr_encrypt_def | {
"file_name": "vale/specs/crypto/Vale.AES.GCTR_BE_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
icb: Vale.Def.Types_s.quad32 ->
plain: FStar.Seq.Base.seq Vale.Def.Types_s.nat8 ->
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32
-> Prims.Pure (FStar.Seq.Base.seq Vale.Def.Types_s.nat8) | {
"end_col": 43,
"end_line": 68,
"start_col": 3,
"start_line": 48
} |
Prims.Tot | val uint16:uinttype U16.t 2 | [
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint16 : uinttype U16.t 2 =
UIntType
(fun x -> U16.v x)
(fun x -> FStar.Int.Cast.uint16_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint16 x)
0us
(fun _ _ -> ())
(fun x y -> x `U16.add` y)
(fun x -> x `U16.mul` 256us)
(fun x -> x `U16.div` 256us) | val uint16:uinttype U16.t 2
let uint16:uinttype U16.t 2 = | false | null | false | UIntType (fun x -> U16.v x)
(fun x -> FStar.Int.Cast.uint16_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint16 x)
0us
(fun _ _ -> ())
(fun x y -> x `U16.add` y)
(fun x -> x `U16.mul` 256us)
(fun x -> x `U16.div` 256us) | {
"checked_file": "LowParse.Spec.Endianness.Instances.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Endianness.Instances.fst"
} | [
"total"
] | [
"LowParse.Spec.Endianness.UIntType",
"FStar.UInt16.t",
"FStar.UInt16.v",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Mul.op_Star",
"FStar.Int.Cast.uint16_to_uint8",
"FStar.UInt8.t",
"Prims.eq2",
"Prims.int",
"FStar.UInt8.v",
"Prims.op_Modulus",
"FStar.Int.Cast.uint8_to_uint16",
"Prims.l_or",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt8.n",
"FStar.UInt16.__uint_to_t",
"Prims.unit",
"FStar.UInt16.add",
"FStar.UInt16.mul",
"FStar.UInt16.div"
] | [] | module LowParse.Spec.Endianness.Instances
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
inline_for_extraction
noextract
let uint8 : uinttype U8.t 1 =
UIntType
(fun x -> U8.v x)
(fun x -> x)
(fun x -> x)
0uy
(fun _ _ -> ())
(fun x y -> x `U8.add` y)
(fun x -> 0uy)
(fun x -> 0uy)
module U16 = FStar.UInt16
inline_for_extraction
noextract | false | false | LowParse.Spec.Endianness.Instances.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint16:uinttype U16.t 2 | [] | LowParse.Spec.Endianness.Instances.uint16 | {
"file_name": "src/lowparse/LowParse.Spec.Endianness.Instances.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Spec.Endianness.uinttype FStar.UInt16.t 2 | {
"end_col": 32,
"end_line": 32,
"start_col": 2,
"start_line": 24
} |
Prims.Tot | val uint32:uinttype U32.t 4 | [
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_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 : uinttype U32.t 4 =
UIntType
(fun x -> U32.v x)
(fun x -> FStar.Int.Cast.uint32_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint32 x)
0ul
(fun _ _ -> ())
(fun x y -> x `U32.add` y)
(fun x -> x `U32.mul` 256ul)
(fun x -> x `U32.div` 256ul) | val uint32:uinttype U32.t 4
let uint32:uinttype U32.t 4 = | false | null | false | UIntType (fun x -> U32.v x)
(fun x -> FStar.Int.Cast.uint32_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint32 x)
0ul
(fun _ _ -> ())
(fun x y -> x `U32.add` y)
(fun x -> x `U32.mul` 256ul)
(fun x -> x `U32.div` 256ul) | {
"checked_file": "LowParse.Spec.Endianness.Instances.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Endianness.Instances.fst"
} | [
"total"
] | [
"LowParse.Spec.Endianness.UIntType",
"FStar.UInt32.t",
"FStar.UInt32.v",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Mul.op_Star",
"FStar.Int.Cast.uint32_to_uint8",
"FStar.UInt8.t",
"Prims.eq2",
"Prims.int",
"FStar.UInt8.v",
"Prims.op_Modulus",
"FStar.Int.Cast.uint8_to_uint32",
"Prims.l_or",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt8.n",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"FStar.UInt32.add",
"FStar.UInt32.mul",
"FStar.UInt32.div"
] | [] | module LowParse.Spec.Endianness.Instances
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
inline_for_extraction
noextract
let uint8 : uinttype U8.t 1 =
UIntType
(fun x -> U8.v x)
(fun x -> x)
(fun x -> x)
0uy
(fun _ _ -> ())
(fun x y -> x `U8.add` y)
(fun x -> 0uy)
(fun x -> 0uy)
module U16 = FStar.UInt16
inline_for_extraction
noextract
let uint16 : uinttype U16.t 2 =
UIntType
(fun x -> U16.v x)
(fun x -> FStar.Int.Cast.uint16_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint16 x)
0us
(fun _ _ -> ())
(fun x y -> x `U16.add` y)
(fun x -> x `U16.mul` 256us)
(fun x -> x `U16.div` 256us)
module U32 = FStar.UInt32
inline_for_extraction
noextract | false | false | LowParse.Spec.Endianness.Instances.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint32:uinttype U32.t 4 | [] | LowParse.Spec.Endianness.Instances.uint32 | {
"file_name": "src/lowparse/LowParse.Spec.Endianness.Instances.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Spec.Endianness.uinttype FStar.UInt32.t 4 | {
"end_col": 32,
"end_line": 47,
"start_col": 2,
"start_line": 39
} |
Prims.Tot | val uint8:uinttype U8.t 1 | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_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 : uinttype U8.t 1 =
UIntType
(fun x -> U8.v x)
(fun x -> x)
(fun x -> x)
0uy
(fun _ _ -> ())
(fun x y -> x `U8.add` y)
(fun x -> 0uy)
(fun x -> 0uy) | val uint8:uinttype U8.t 1
let uint8:uinttype U8.t 1 = | false | null | false | UIntType (fun x -> U8.v x)
(fun x -> x)
(fun x -> x)
0uy
(fun _ _ -> ())
(fun x y -> x `U8.add` y)
(fun x -> 0uy)
(fun x -> 0uy) | {
"checked_file": "LowParse.Spec.Endianness.Instances.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Endianness.Instances.fst"
} | [
"total"
] | [
"LowParse.Spec.Endianness.UIntType",
"FStar.UInt8.t",
"FStar.UInt8.v",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Mul.op_Star",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Prims.l_or",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt8.n",
"FStar.UInt8.__uint_to_t",
"Prims.unit",
"FStar.UInt8.add"
] | [] | module LowParse.Spec.Endianness.Instances
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
inline_for_extraction
noextract | false | false | LowParse.Spec.Endianness.Instances.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint8:uinttype U8.t 1 | [] | LowParse.Spec.Endianness.Instances.uint8 | {
"file_name": "src/lowparse/LowParse.Spec.Endianness.Instances.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Spec.Endianness.uinttype FStar.UInt8.t 1 | {
"end_col": 18,
"end_line": 17,
"start_col": 2,
"start_line": 9
} |
Prims.Tot | val uint64:uinttype U64.t 8 | [
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint64 : uinttype U64.t 8 =
UIntType
(fun x -> U64.v x)
(fun x -> FStar.Int.Cast.uint64_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint64 x)
0uL
(fun _ _ -> ())
(fun x y -> x `U64.add` y)
(fun x -> x `U64.mul` 256uL)
(fun x -> x `U64.div` 256uL) | val uint64:uinttype U64.t 8
let uint64:uinttype U64.t 8 = | false | null | false | UIntType (fun x -> U64.v x)
(fun x -> FStar.Int.Cast.uint64_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint64 x)
0uL
(fun _ _ -> ())
(fun x y -> x `U64.add` y)
(fun x -> x `U64.mul` 256uL)
(fun x -> x `U64.div` 256uL) | {
"checked_file": "LowParse.Spec.Endianness.Instances.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Endianness.Instances.fst"
} | [
"total"
] | [
"LowParse.Spec.Endianness.UIntType",
"FStar.UInt64.t",
"FStar.UInt64.v",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Mul.op_Star",
"FStar.Int.Cast.uint64_to_uint8",
"FStar.UInt8.t",
"Prims.eq2",
"Prims.int",
"FStar.UInt8.v",
"Prims.op_Modulus",
"FStar.Int.Cast.uint8_to_uint64",
"Prims.l_or",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt8.n",
"FStar.UInt64.__uint_to_t",
"Prims.unit",
"FStar.UInt64.add",
"FStar.UInt64.mul",
"FStar.UInt64.div"
] | [] | module LowParse.Spec.Endianness.Instances
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
inline_for_extraction
noextract
let uint8 : uinttype U8.t 1 =
UIntType
(fun x -> U8.v x)
(fun x -> x)
(fun x -> x)
0uy
(fun _ _ -> ())
(fun x y -> x `U8.add` y)
(fun x -> 0uy)
(fun x -> 0uy)
module U16 = FStar.UInt16
inline_for_extraction
noextract
let uint16 : uinttype U16.t 2 =
UIntType
(fun x -> U16.v x)
(fun x -> FStar.Int.Cast.uint16_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint16 x)
0us
(fun _ _ -> ())
(fun x y -> x `U16.add` y)
(fun x -> x `U16.mul` 256us)
(fun x -> x `U16.div` 256us)
module U32 = FStar.UInt32
inline_for_extraction
noextract
let uint32 : uinttype U32.t 4 =
UIntType
(fun x -> U32.v x)
(fun x -> FStar.Int.Cast.uint32_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint32 x)
0ul
(fun _ _ -> ())
(fun x y -> x `U32.add` y)
(fun x -> x `U32.mul` 256ul)
(fun x -> x `U32.div` 256ul)
module U64 = FStar.UInt64
inline_for_extraction
noextract | false | false | LowParse.Spec.Endianness.Instances.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val uint64:uinttype U64.t 8 | [] | LowParse.Spec.Endianness.Instances.uint64 | {
"file_name": "src/lowparse/LowParse.Spec.Endianness.Instances.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | LowParse.Spec.Endianness.uinttype FStar.UInt64.t 8 | {
"end_col": 32,
"end_line": 62,
"start_col": 2,
"start_line": 54
} |
Prims.Tot | val bounded_integer (i: integer_size) : Tot (uinttype (bounded_integer i) i) | [
{
"abbrev": false,
"full_module": "LowParse.Spec.BoundedInt",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.UInt16",
"short_module": "U16"
},
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Endianness",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bounded_integer
(i: integer_size)
: Tot (uinttype (bounded_integer i) i)
= UIntType
(fun (x: bounded_integer i) -> bounded_integer_prop_equiv i x; U32.v x)
(fun x -> FStar.Int.Cast.uint32_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint32 x)
0ul
(fun _ _ -> ())
(fun x y -> x `U32.add` y)
(fun x -> x `U32.mul` 256ul)
(fun x -> x `U32.div` 256ul) | val bounded_integer (i: integer_size) : Tot (uinttype (bounded_integer i) i)
let bounded_integer (i: integer_size) : Tot (uinttype (bounded_integer i) i) = | false | null | false | UIntType
(fun (x: bounded_integer i) ->
bounded_integer_prop_equiv i x;
U32.v x)
(fun x -> FStar.Int.Cast.uint32_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint32 x)
0ul
(fun _ _ -> ())
(fun x y -> x `U32.add` y)
(fun x -> x `U32.mul` 256ul)
(fun x -> x `U32.div` 256ul) | {
"checked_file": "LowParse.Spec.Endianness.Instances.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Endianness.fst.checked",
"LowParse.Spec.BoundedInt.fsti.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.UInt16.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Endianness.Instances.fst"
} | [
"total"
] | [
"LowParse.Spec.BoundedInt.integer_size",
"LowParse.Spec.Endianness.UIntType",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt32.v",
"Prims.unit",
"LowParse.Spec.BoundedInt.bounded_integer_prop_equiv",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.pow2",
"FStar.Mul.op_Star",
"FStar.Int.Cast.uint32_to_uint8",
"FStar.UInt8.t",
"Prims.eq2",
"Prims.int",
"FStar.UInt8.v",
"Prims.op_Modulus",
"FStar.Int.Cast.uint8_to_uint32",
"Prims.l_or",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt8.n",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.add",
"FStar.UInt32.mul",
"FStar.UInt32.div",
"LowParse.Spec.Endianness.uinttype"
] | [] | module LowParse.Spec.Endianness.Instances
include LowParse.Spec.Endianness
module U8 = FStar.UInt8
inline_for_extraction
noextract
let uint8 : uinttype U8.t 1 =
UIntType
(fun x -> U8.v x)
(fun x -> x)
(fun x -> x)
0uy
(fun _ _ -> ())
(fun x y -> x `U8.add` y)
(fun x -> 0uy)
(fun x -> 0uy)
module U16 = FStar.UInt16
inline_for_extraction
noextract
let uint16 : uinttype U16.t 2 =
UIntType
(fun x -> U16.v x)
(fun x -> FStar.Int.Cast.uint16_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint16 x)
0us
(fun _ _ -> ())
(fun x y -> x `U16.add` y)
(fun x -> x `U16.mul` 256us)
(fun x -> x `U16.div` 256us)
module U32 = FStar.UInt32
inline_for_extraction
noextract
let uint32 : uinttype U32.t 4 =
UIntType
(fun x -> U32.v x)
(fun x -> FStar.Int.Cast.uint32_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint32 x)
0ul
(fun _ _ -> ())
(fun x y -> x `U32.add` y)
(fun x -> x `U32.mul` 256ul)
(fun x -> x `U32.div` 256ul)
module U64 = FStar.UInt64
inline_for_extraction
noextract
let uint64 : uinttype U64.t 8 =
UIntType
(fun x -> U64.v x)
(fun x -> FStar.Int.Cast.uint64_to_uint8 x)
(fun x -> FStar.Int.Cast.uint8_to_uint64 x)
0uL
(fun _ _ -> ())
(fun x y -> x `U64.add` y)
(fun x -> x `U64.mul` 256uL)
(fun x -> x `U64.div` 256uL)
open LowParse.Spec.BoundedInt
inline_for_extraction
noextract
let bounded_integer
(i: integer_size) | false | false | LowParse.Spec.Endianness.Instances.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bounded_integer (i: integer_size) : Tot (uinttype (bounded_integer i) i) | [] | LowParse.Spec.Endianness.Instances.bounded_integer | {
"file_name": "src/lowparse/LowParse.Spec.Endianness.Instances.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | i: LowParse.Spec.BoundedInt.integer_size
-> LowParse.Spec.Endianness.uinttype (LowParse.Spec.BoundedInt.bounded_integer i) i | {
"end_col": 32,
"end_line": 79,
"start_col": 2,
"start_line": 71
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_mul = S.aff_point_mul | let aff_point_mul = | false | null | false | S.aff_point_mul | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"total"
] | [
"Spec.K256.aff_point_mul"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | false | true | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_mul : a: Prims.nat -> p: Spec.K256.PointOps.aff_point -> Spec.K256.PointOps.aff_point | [] | Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.nat -> p: Spec.K256.PointOps.aff_point -> Spec.K256.PointOps.aff_point | {
"end_col": 35,
"end_line": 15,
"start_col": 20,
"start_line": 15
} |
|
Prims.Tot | val aff_point_mul_neg (a: int) (p: S.aff_point) : S.aff_point | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a | val aff_point_mul_neg (a: int) (p: S.aff_point) : S.aff_point
let aff_point_mul_neg (a: int) (p: S.aff_point) : S.aff_point = | false | null | false | LE.pow_neg S.mk_k256_abelian_group p a | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"total"
] | [
"Prims.int",
"Spec.K256.PointOps.aff_point",
"Lib.Exponentiation.Definition.pow_neg",
"Spec.K256.mk_k256_abelian_group"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a | false | true | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_mul_neg (a: int) (p: S.aff_point) : S.aff_point | [] | Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.int -> p: Spec.K256.PointOps.aff_point -> Spec.K256.PointOps.aff_point | {
"end_col": 40,
"end_line": 19,
"start_col": 2,
"start_line": 19
} |
FStar.Pervasives.Lemma | val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p)) | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_aff_point_mul_neg_mul a b p =
LE.lemma_pow_neg_mul S.mk_k256_abelian_group p a b | val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p))
let lemma_aff_point_mul_neg_mul a b p = | false | null | true | LE.lemma_pow_neg_mul S.mk_k256_abelian_group p a b | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.int",
"Spec.K256.PointOps.aff_point",
"Lib.Exponentiation.Definition.lemma_pow_neg_mul",
"Spec.K256.mk_k256_abelian_group",
"Prims.unit"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a
let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a
assume
val lemma_order_of_curve_group (p:S.aff_point) :
Lemma (aff_point_mul S.q p == S.aff_point_at_inf)
(**
Properties for Elliptic Curve Scalar Multiplication in affine coordinates
*)
// [a + b]P = [a]P + [b]P
val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p))
let lemma_aff_point_mul_neg_add a b p =
LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b
// [a * b]P = [b]([a]P)
val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p)) | false | false | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p)) | [] | Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_mul | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.int -> b: Prims.int -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg (a * b) p ==
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg b
(Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg a p)) | {
"end_col": 52,
"end_line": 44,
"start_col": 2,
"start_line": 44
} |
FStar.Pervasives.Lemma | val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p)) | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_aff_point_mul_neg_add a b p =
LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b | val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p))
let lemma_aff_point_mul_neg_add a b p = | false | null | true | LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.int",
"Spec.K256.PointOps.aff_point",
"Lib.Exponentiation.Definition.lemma_pow_neg_add",
"Spec.K256.mk_k256_abelian_group",
"Prims.unit"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a
let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a
assume
val lemma_order_of_curve_group (p:S.aff_point) :
Lemma (aff_point_mul S.q p == S.aff_point_at_inf)
(**
Properties for Elliptic Curve Scalar Multiplication in affine coordinates
*)
// [a + b]P = [a]P + [b]P
val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p)) | false | false | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p)) | [] | Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_add | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.int -> b: Prims.int -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg (a + b) p ==
Spec.K256.PointOps.aff_point_add (Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg a p)
(Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg b p)) | {
"end_col": 52,
"end_line": 36,
"start_col": 2,
"start_line": 36
} |
FStar.Pervasives.Lemma | val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p)) | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_aff_point_mul_neg_mul_add a b c p =
lemma_aff_point_mul_neg_add (a * b) c p;
lemma_aff_point_mul_neg_mul a b p | val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p))
let lemma_aff_point_mul_neg_mul_add a b c p = | false | null | true | lemma_aff_point_mul_neg_add (a * b) c p;
lemma_aff_point_mul_neg_mul a b p | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.int",
"Spec.K256.PointOps.aff_point",
"Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_mul",
"Prims.unit",
"Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_add",
"FStar.Mul.op_Star"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a
let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a
assume
val lemma_order_of_curve_group (p:S.aff_point) :
Lemma (aff_point_mul S.q p == S.aff_point_at_inf)
(**
Properties for Elliptic Curve Scalar Multiplication in affine coordinates
*)
// [a + b]P = [a]P + [b]P
val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p))
let lemma_aff_point_mul_neg_add a b p =
LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b
// [a * b]P = [b]([a]P)
val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p))
let lemma_aff_point_mul_neg_mul a b p =
LE.lemma_pow_neg_mul S.mk_k256_abelian_group p a b
// [a * b + c]P = [b]([a]P) + [c]P
val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p)) | false | false | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p)) | [] | Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_mul_add | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.int -> b: Prims.int -> c: Prims.int -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg (a * b + c) p ==
Spec.K256.PointOps.aff_point_add (Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg b
(Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg a p))
(Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg c p)) | {
"end_col": 35,
"end_line": 54,
"start_col": 2,
"start_line": 53
} |
FStar.Pervasives.Lemma | val aff_point_mul_neg_lemma: a:nat -> p:S.aff_point ->
Lemma (S.aff_point_negate (aff_point_mul a p) == aff_point_mul a (S.aff_point_negate p)) | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_mul_neg_lemma a p =
LE.lemma_inverse_pow S.mk_k256_abelian_group p a | val aff_point_mul_neg_lemma: a:nat -> p:S.aff_point ->
Lemma (S.aff_point_negate (aff_point_mul a p) == aff_point_mul a (S.aff_point_negate p))
let aff_point_mul_neg_lemma a p = | false | null | true | LE.lemma_inverse_pow S.mk_k256_abelian_group p a | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Spec.K256.PointOps.aff_point",
"Lib.Exponentiation.Definition.lemma_inverse_pow",
"Spec.K256.mk_k256_abelian_group",
"Prims.unit"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a
let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a
assume
val lemma_order_of_curve_group (p:S.aff_point) :
Lemma (aff_point_mul S.q p == S.aff_point_at_inf)
(**
Properties for Elliptic Curve Scalar Multiplication in affine coordinates
*)
// [a + b]P = [a]P + [b]P
val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p))
let lemma_aff_point_mul_neg_add a b p =
LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b
// [a * b]P = [b]([a]P)
val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p))
let lemma_aff_point_mul_neg_mul a b p =
LE.lemma_pow_neg_mul S.mk_k256_abelian_group p a b
// [a * b + c]P = [b]([a]P) + [c]P
val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p))
let lemma_aff_point_mul_neg_mul_add a b c p =
lemma_aff_point_mul_neg_add (a * b) c p;
lemma_aff_point_mul_neg_mul a b p
// [a]P = [a % S.q]P
val lemma_aff_point_mul_neg_modq (a:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg a p == aff_point_mul (a % S.q) p)
let lemma_aff_point_mul_neg_modq a p =
calc (==) {
aff_point_mul_neg a p;
(==) { Math.Lemmas.euclidean_division_definition a S.q }
aff_point_mul_neg (a / S.q * S.q + a % S.q) p;
(==) { lemma_aff_point_mul_neg_add (a / S.q * S.q) (a % S.q) p }
S.aff_point_add (aff_point_mul_neg (a / S.q * S.q) p) (aff_point_mul_neg (a % S.q) p);
(==) { lemma_aff_point_mul_neg_mul (a / S.q) S.q p }
S.aff_point_add
(aff_point_mul S.q (aff_point_mul_neg (a / S.q) p))
(aff_point_mul (a % S.q) p);
(==) { lemma_order_of_curve_group (aff_point_mul_neg (a / S.q) p) }
S.aff_point_add S.aff_point_at_inf (aff_point_mul (a % S.q) p);
(==) { LS.aff_point_add_comm_lemma S.aff_point_at_inf (aff_point_mul (a % S.q) p) }
S.aff_point_add (aff_point_mul (a % S.q) p) S.aff_point_at_inf;
(==) { LS.aff_point_at_inf_lemma (aff_point_mul (a % S.q) p) }
aff_point_mul (a % S.q) p;
}
// [a]P = [(-a) % q](-P)
val lemma_aff_point_mul_neg: a:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul ((- a) % S.q) (S.aff_point_negate p) == aff_point_mul a p)
let lemma_aff_point_mul_neg a p =
let cm = S.mk_k256_comm_monoid in
let ag = S.mk_k256_abelian_group in
let p_neg = S.aff_point_negate p in
if a > 0 then begin
calc (==) {
aff_point_mul ((- a) % S.q) p_neg;
(==) { lemma_aff_point_mul_neg_modq (- a) p_neg }
aff_point_mul_neg (- a) p_neg;
(==) { }
S.aff_point_negate (aff_point_mul a p_neg);
(==) { LE.lemma_inverse_pow ag p a }
S.aff_point_negate (S.aff_point_negate (aff_point_mul a p));
(==) { LE.lemma_inverse_id ag (aff_point_mul a p) }
aff_point_mul a p;
} end
else begin
LE.lemma_pow0 cm p;
LE.lemma_pow0 cm p_neg end
//--------------------------------------------
// [a]([b]P) = [b]([a]P)
val aff_point_mul_mul_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (aff_point_mul b p) == aff_point_mul b (aff_point_mul a p))
let aff_point_mul_mul_lemma a b p =
calc (==) {
aff_point_mul a (aff_point_mul b p);
(==) { LE.lemma_pow_mul S.mk_k256_comm_monoid p b a }
aff_point_mul (a * b) p;
(==) { LE.lemma_pow_mul S.mk_k256_comm_monoid p a b }
aff_point_mul b (aff_point_mul a p);
}
// -[a]P = [a](-P)
val aff_point_mul_neg_lemma: a:nat -> p:S.aff_point ->
Lemma (S.aff_point_negate (aff_point_mul a p) == aff_point_mul a (S.aff_point_negate p)) | false | false | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_mul_neg_lemma: a:nat -> p:S.aff_point ->
Lemma (S.aff_point_negate (aff_point_mul a p) == aff_point_mul a (S.aff_point_negate p)) | [] | Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.nat -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
Spec.K256.PointOps.aff_point_negate (Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul a p) ==
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul a (Spec.K256.PointOps.aff_point_negate p)) | {
"end_col": 50,
"end_line": 126,
"start_col": 2,
"start_line": 126
} |
FStar.Pervasives.Lemma | val aff_point_mul_mul_neg_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (S.aff_point_negate (aff_point_mul b p)) ==
aff_point_mul b (S.aff_point_negate (aff_point_mul a p))) | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_mul_mul_neg_lemma a b p =
let p_neg = S.aff_point_negate p in
calc (==) {
aff_point_mul a (S.aff_point_negate (aff_point_mul b p));
(==) { aff_point_mul_neg_lemma b p }
aff_point_mul a (aff_point_mul b p_neg);
(==) { aff_point_mul_mul_lemma a b p_neg }
aff_point_mul b (aff_point_mul a p_neg);
(==) { aff_point_mul_neg_lemma a p }
aff_point_mul b (S.aff_point_negate (aff_point_mul a p));
} | val aff_point_mul_mul_neg_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (S.aff_point_negate (aff_point_mul b p)) ==
aff_point_mul b (S.aff_point_negate (aff_point_mul a p)))
let aff_point_mul_mul_neg_lemma a b p = | false | null | true | let p_neg = S.aff_point_negate p in
calc ( == ) {
aff_point_mul a (S.aff_point_negate (aff_point_mul b p));
( == ) { aff_point_mul_neg_lemma b p }
aff_point_mul a (aff_point_mul b p_neg);
( == ) { aff_point_mul_mul_lemma a b p_neg }
aff_point_mul b (aff_point_mul a p_neg);
( == ) { aff_point_mul_neg_lemma a p }
aff_point_mul b (S.aff_point_negate (aff_point_mul a p));
} | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Spec.K256.PointOps.aff_point",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul",
"Spec.K256.PointOps.aff_point_negate",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg_lemma",
"Prims.squash",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_mul_lemma"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a
let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a
assume
val lemma_order_of_curve_group (p:S.aff_point) :
Lemma (aff_point_mul S.q p == S.aff_point_at_inf)
(**
Properties for Elliptic Curve Scalar Multiplication in affine coordinates
*)
// [a + b]P = [a]P + [b]P
val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p))
let lemma_aff_point_mul_neg_add a b p =
LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b
// [a * b]P = [b]([a]P)
val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p))
let lemma_aff_point_mul_neg_mul a b p =
LE.lemma_pow_neg_mul S.mk_k256_abelian_group p a b
// [a * b + c]P = [b]([a]P) + [c]P
val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p))
let lemma_aff_point_mul_neg_mul_add a b c p =
lemma_aff_point_mul_neg_add (a * b) c p;
lemma_aff_point_mul_neg_mul a b p
// [a]P = [a % S.q]P
val lemma_aff_point_mul_neg_modq (a:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg a p == aff_point_mul (a % S.q) p)
let lemma_aff_point_mul_neg_modq a p =
calc (==) {
aff_point_mul_neg a p;
(==) { Math.Lemmas.euclidean_division_definition a S.q }
aff_point_mul_neg (a / S.q * S.q + a % S.q) p;
(==) { lemma_aff_point_mul_neg_add (a / S.q * S.q) (a % S.q) p }
S.aff_point_add (aff_point_mul_neg (a / S.q * S.q) p) (aff_point_mul_neg (a % S.q) p);
(==) { lemma_aff_point_mul_neg_mul (a / S.q) S.q p }
S.aff_point_add
(aff_point_mul S.q (aff_point_mul_neg (a / S.q) p))
(aff_point_mul (a % S.q) p);
(==) { lemma_order_of_curve_group (aff_point_mul_neg (a / S.q) p) }
S.aff_point_add S.aff_point_at_inf (aff_point_mul (a % S.q) p);
(==) { LS.aff_point_add_comm_lemma S.aff_point_at_inf (aff_point_mul (a % S.q) p) }
S.aff_point_add (aff_point_mul (a % S.q) p) S.aff_point_at_inf;
(==) { LS.aff_point_at_inf_lemma (aff_point_mul (a % S.q) p) }
aff_point_mul (a % S.q) p;
}
// [a]P = [(-a) % q](-P)
val lemma_aff_point_mul_neg: a:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul ((- a) % S.q) (S.aff_point_negate p) == aff_point_mul a p)
let lemma_aff_point_mul_neg a p =
let cm = S.mk_k256_comm_monoid in
let ag = S.mk_k256_abelian_group in
let p_neg = S.aff_point_negate p in
if a > 0 then begin
calc (==) {
aff_point_mul ((- a) % S.q) p_neg;
(==) { lemma_aff_point_mul_neg_modq (- a) p_neg }
aff_point_mul_neg (- a) p_neg;
(==) { }
S.aff_point_negate (aff_point_mul a p_neg);
(==) { LE.lemma_inverse_pow ag p a }
S.aff_point_negate (S.aff_point_negate (aff_point_mul a p));
(==) { LE.lemma_inverse_id ag (aff_point_mul a p) }
aff_point_mul a p;
} end
else begin
LE.lemma_pow0 cm p;
LE.lemma_pow0 cm p_neg end
//--------------------------------------------
// [a]([b]P) = [b]([a]P)
val aff_point_mul_mul_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (aff_point_mul b p) == aff_point_mul b (aff_point_mul a p))
let aff_point_mul_mul_lemma a b p =
calc (==) {
aff_point_mul a (aff_point_mul b p);
(==) { LE.lemma_pow_mul S.mk_k256_comm_monoid p b a }
aff_point_mul (a * b) p;
(==) { LE.lemma_pow_mul S.mk_k256_comm_monoid p a b }
aff_point_mul b (aff_point_mul a p);
}
// -[a]P = [a](-P)
val aff_point_mul_neg_lemma: a:nat -> p:S.aff_point ->
Lemma (S.aff_point_negate (aff_point_mul a p) == aff_point_mul a (S.aff_point_negate p))
let aff_point_mul_neg_lemma a p =
LE.lemma_inverse_pow S.mk_k256_abelian_group p a
// [a](-[b]P) = [b](-[a]P)
val aff_point_mul_mul_neg_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (S.aff_point_negate (aff_point_mul b p)) ==
aff_point_mul b (S.aff_point_negate (aff_point_mul a p))) | false | false | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_mul_mul_neg_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (S.aff_point_negate (aff_point_mul b p)) ==
aff_point_mul b (S.aff_point_negate (aff_point_mul a p))) | [] | Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_mul_neg_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.nat -> b: Prims.nat -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul a
(Spec.K256.PointOps.aff_point_negate (Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul b p)) ==
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul b
(Spec.K256.PointOps.aff_point_negate (Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul a p))) | {
"end_col": 3,
"end_line": 145,
"start_col": 39,
"start_line": 134
} |
FStar.Pervasives.Lemma | val lemma_aff_point_mul_neg: a:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul ((- a) % S.q) (S.aff_point_negate p) == aff_point_mul a p) | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_aff_point_mul_neg a p =
let cm = S.mk_k256_comm_monoid in
let ag = S.mk_k256_abelian_group in
let p_neg = S.aff_point_negate p in
if a > 0 then begin
calc (==) {
aff_point_mul ((- a) % S.q) p_neg;
(==) { lemma_aff_point_mul_neg_modq (- a) p_neg }
aff_point_mul_neg (- a) p_neg;
(==) { }
S.aff_point_negate (aff_point_mul a p_neg);
(==) { LE.lemma_inverse_pow ag p a }
S.aff_point_negate (S.aff_point_negate (aff_point_mul a p));
(==) { LE.lemma_inverse_id ag (aff_point_mul a p) }
aff_point_mul a p;
} end
else begin
LE.lemma_pow0 cm p;
LE.lemma_pow0 cm p_neg end | val lemma_aff_point_mul_neg: a:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul ((- a) % S.q) (S.aff_point_negate p) == aff_point_mul a p)
let lemma_aff_point_mul_neg a p = | false | null | true | let cm = S.mk_k256_comm_monoid in
let ag = S.mk_k256_abelian_group in
let p_neg = S.aff_point_negate p in
if a > 0
then
calc ( == ) {
aff_point_mul ((- a) % S.q) p_neg;
( == ) { lemma_aff_point_mul_neg_modq (- a) p_neg }
aff_point_mul_neg (- a) p_neg;
( == ) { () }
S.aff_point_negate (aff_point_mul a p_neg);
( == ) { LE.lemma_inverse_pow ag p a }
S.aff_point_negate (S.aff_point_negate (aff_point_mul a p));
( == ) { LE.lemma_inverse_id ag (aff_point_mul a p) }
aff_point_mul a p;
}
else
(LE.lemma_pow0 cm p;
LE.lemma_pow0 cm p_neg) | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"lemma"
] | [
"Spec.K256.PointOps.qelem",
"Spec.K256.PointOps.aff_point",
"Prims.op_GreaterThan",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul",
"Prims.op_Modulus",
"Prims.op_Minus",
"Spec.K256.PointOps.q",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Spec.K256.PointOps.aff_point_negate",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_modq",
"Prims.squash",
"Lib.Exponentiation.Definition.lemma_inverse_pow",
"Lib.Exponentiation.Definition.lemma_inverse_id",
"Prims.bool",
"Lib.Exponentiation.Definition.lemma_pow0",
"Lib.Exponentiation.Definition.abelian_group",
"Spec.K256.mk_k256_abelian_group",
"Lib.Exponentiation.Definition.comm_monoid",
"Spec.K256.mk_k256_comm_monoid"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a
let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a
assume
val lemma_order_of_curve_group (p:S.aff_point) :
Lemma (aff_point_mul S.q p == S.aff_point_at_inf)
(**
Properties for Elliptic Curve Scalar Multiplication in affine coordinates
*)
// [a + b]P = [a]P + [b]P
val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p))
let lemma_aff_point_mul_neg_add a b p =
LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b
// [a * b]P = [b]([a]P)
val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p))
let lemma_aff_point_mul_neg_mul a b p =
LE.lemma_pow_neg_mul S.mk_k256_abelian_group p a b
// [a * b + c]P = [b]([a]P) + [c]P
val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p))
let lemma_aff_point_mul_neg_mul_add a b c p =
lemma_aff_point_mul_neg_add (a * b) c p;
lemma_aff_point_mul_neg_mul a b p
// [a]P = [a % S.q]P
val lemma_aff_point_mul_neg_modq (a:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg a p == aff_point_mul (a % S.q) p)
let lemma_aff_point_mul_neg_modq a p =
calc (==) {
aff_point_mul_neg a p;
(==) { Math.Lemmas.euclidean_division_definition a S.q }
aff_point_mul_neg (a / S.q * S.q + a % S.q) p;
(==) { lemma_aff_point_mul_neg_add (a / S.q * S.q) (a % S.q) p }
S.aff_point_add (aff_point_mul_neg (a / S.q * S.q) p) (aff_point_mul_neg (a % S.q) p);
(==) { lemma_aff_point_mul_neg_mul (a / S.q) S.q p }
S.aff_point_add
(aff_point_mul S.q (aff_point_mul_neg (a / S.q) p))
(aff_point_mul (a % S.q) p);
(==) { lemma_order_of_curve_group (aff_point_mul_neg (a / S.q) p) }
S.aff_point_add S.aff_point_at_inf (aff_point_mul (a % S.q) p);
(==) { LS.aff_point_add_comm_lemma S.aff_point_at_inf (aff_point_mul (a % S.q) p) }
S.aff_point_add (aff_point_mul (a % S.q) p) S.aff_point_at_inf;
(==) { LS.aff_point_at_inf_lemma (aff_point_mul (a % S.q) p) }
aff_point_mul (a % S.q) p;
}
// [a]P = [(-a) % q](-P)
val lemma_aff_point_mul_neg: a:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul ((- a) % S.q) (S.aff_point_negate p) == aff_point_mul a p) | false | false | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_aff_point_mul_neg: a:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul ((- a) % S.q) (S.aff_point_negate p) == aff_point_mul a p) | [] | Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.K256.PointOps.qelem -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul ((- a) % Spec.K256.PointOps.q)
(Spec.K256.PointOps.aff_point_negate p) ==
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul a p) | {
"end_col": 30,
"end_line": 103,
"start_col": 33,
"start_line": 85
} |
FStar.Pervasives.Lemma | val lemma_aff_point_mul_neg_modq (a:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg a p == aff_point_mul (a % S.q) p) | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_aff_point_mul_neg_modq a p =
calc (==) {
aff_point_mul_neg a p;
(==) { Math.Lemmas.euclidean_division_definition a S.q }
aff_point_mul_neg (a / S.q * S.q + a % S.q) p;
(==) { lemma_aff_point_mul_neg_add (a / S.q * S.q) (a % S.q) p }
S.aff_point_add (aff_point_mul_neg (a / S.q * S.q) p) (aff_point_mul_neg (a % S.q) p);
(==) { lemma_aff_point_mul_neg_mul (a / S.q) S.q p }
S.aff_point_add
(aff_point_mul S.q (aff_point_mul_neg (a / S.q) p))
(aff_point_mul (a % S.q) p);
(==) { lemma_order_of_curve_group (aff_point_mul_neg (a / S.q) p) }
S.aff_point_add S.aff_point_at_inf (aff_point_mul (a % S.q) p);
(==) { LS.aff_point_add_comm_lemma S.aff_point_at_inf (aff_point_mul (a % S.q) p) }
S.aff_point_add (aff_point_mul (a % S.q) p) S.aff_point_at_inf;
(==) { LS.aff_point_at_inf_lemma (aff_point_mul (a % S.q) p) }
aff_point_mul (a % S.q) p;
} | val lemma_aff_point_mul_neg_modq (a:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg a p == aff_point_mul (a % S.q) p)
let lemma_aff_point_mul_neg_modq a p = | false | null | true | calc ( == ) {
aff_point_mul_neg a p;
( == ) { Math.Lemmas.euclidean_division_definition a S.q }
aff_point_mul_neg ((a / S.q) * S.q + a % S.q) p;
( == ) { lemma_aff_point_mul_neg_add ((a / S.q) * S.q) (a % S.q) p }
S.aff_point_add (aff_point_mul_neg ((a / S.q) * S.q) p) (aff_point_mul_neg (a % S.q) p);
( == ) { lemma_aff_point_mul_neg_mul (a / S.q) S.q p }
S.aff_point_add (aff_point_mul S.q (aff_point_mul_neg (a / S.q) p)) (aff_point_mul (a % S.q) p);
( == ) { lemma_order_of_curve_group (aff_point_mul_neg (a / S.q) p) }
S.aff_point_add S.aff_point_at_inf (aff_point_mul (a % S.q) p);
( == ) { LS.aff_point_add_comm_lemma S.aff_point_at_inf (aff_point_mul (a % S.q) p) }
S.aff_point_add (aff_point_mul (a % S.q) p) S.aff_point_at_inf;
( == ) { LS.aff_point_at_inf_lemma (aff_point_mul (a % S.q) p) }
aff_point_mul (a % S.q) p;
} | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.int",
"Spec.K256.PointOps.aff_point",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul",
"Prims.op_Modulus",
"Spec.K256.PointOps.q",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"Spec.K256.PointOps.aff_point_add",
"Spec.K256.PointOps.aff_point_at_inf",
"Prims.op_Division",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.euclidean_division_definition",
"Prims.squash",
"Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_add",
"Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_mul",
"Hacl.Spec.K256.ECSM.Lemmas.lemma_order_of_curve_group",
"Spec.K256.Lemmas.aff_point_add_comm_lemma",
"Spec.K256.Lemmas.aff_point_at_inf_lemma"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a
let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a
assume
val lemma_order_of_curve_group (p:S.aff_point) :
Lemma (aff_point_mul S.q p == S.aff_point_at_inf)
(**
Properties for Elliptic Curve Scalar Multiplication in affine coordinates
*)
// [a + b]P = [a]P + [b]P
val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p))
let lemma_aff_point_mul_neg_add a b p =
LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b
// [a * b]P = [b]([a]P)
val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p))
let lemma_aff_point_mul_neg_mul a b p =
LE.lemma_pow_neg_mul S.mk_k256_abelian_group p a b
// [a * b + c]P = [b]([a]P) + [c]P
val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p))
let lemma_aff_point_mul_neg_mul_add a b c p =
lemma_aff_point_mul_neg_add (a * b) c p;
lemma_aff_point_mul_neg_mul a b p
// [a]P = [a % S.q]P
val lemma_aff_point_mul_neg_modq (a:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg a p == aff_point_mul (a % S.q) p) | false | false | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_aff_point_mul_neg_modq (a:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg a p == aff_point_mul (a % S.q) p) | [] | Hacl.Spec.K256.ECSM.Lemmas.lemma_aff_point_mul_neg_modq | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.int -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_neg a p ==
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul (a % Spec.K256.PointOps.q) p) | {
"end_col": 3,
"end_line": 78,
"start_col": 2,
"start_line": 62
} |
FStar.Pervasives.Lemma | val aff_point_mul_mul_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (aff_point_mul b p) == aff_point_mul b (aff_point_mul a p)) | [
{
"abbrev": true,
"full_module": "Spec.K256.Lemmas",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.K256",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.K256.ECSM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let aff_point_mul_mul_lemma a b p =
calc (==) {
aff_point_mul a (aff_point_mul b p);
(==) { LE.lemma_pow_mul S.mk_k256_comm_monoid p b a }
aff_point_mul (a * b) p;
(==) { LE.lemma_pow_mul S.mk_k256_comm_monoid p a b }
aff_point_mul b (aff_point_mul a p);
} | val aff_point_mul_mul_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (aff_point_mul b p) == aff_point_mul b (aff_point_mul a p))
let aff_point_mul_mul_lemma a b p = | false | null | true | calc ( == ) {
aff_point_mul a (aff_point_mul b p);
( == ) { LE.lemma_pow_mul S.mk_k256_comm_monoid p b a }
aff_point_mul (a * b) p;
( == ) { LE.lemma_pow_mul S.mk_k256_comm_monoid p a b }
aff_point_mul b (aff_point_mul a p);
} | {
"checked_file": "Hacl.Spec.K256.ECSM.Lemmas.fst.checked",
"dependencies": [
"Spec.K256.Lemmas.fsti.checked",
"Spec.K256.fst.checked",
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.K256.ECSM.Lemmas.fst"
} | [
"lemma"
] | [
"Prims.nat",
"Spec.K256.PointOps.aff_point",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"Prims.unit",
"FStar.Calc.calc_step",
"FStar.Mul.op_Star",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"Lib.Exponentiation.Definition.lemma_pow_mul",
"Spec.K256.mk_k256_comm_monoid",
"Prims.squash"
] | [] | module Hacl.Spec.K256.ECSM.Lemmas
open FStar.Mul
module M = Lib.NatMod
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module S = Spec.K256
module LS = Spec.K256.Lemmas
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
// [a]P in affine coordinates for a >= 0
let aff_point_mul = S.aff_point_mul
// [a]P in affine coordinates for any a
let aff_point_mul_neg (a:int) (p:S.aff_point) : S.aff_point =
LE.pow_neg S.mk_k256_abelian_group p a
assume
val lemma_order_of_curve_group (p:S.aff_point) :
Lemma (aff_point_mul S.q p == S.aff_point_at_inf)
(**
Properties for Elliptic Curve Scalar Multiplication in affine coordinates
*)
// [a + b]P = [a]P + [b]P
val lemma_aff_point_mul_neg_add (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a + b) p ==
S.aff_point_add (aff_point_mul_neg a p) (aff_point_mul_neg b p))
let lemma_aff_point_mul_neg_add a b p =
LE.lemma_pow_neg_add S.mk_k256_abelian_group p a b
// [a * b]P = [b]([a]P)
val lemma_aff_point_mul_neg_mul (a b:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b) p == aff_point_mul_neg b (aff_point_mul_neg a p))
let lemma_aff_point_mul_neg_mul a b p =
LE.lemma_pow_neg_mul S.mk_k256_abelian_group p a b
// [a * b + c]P = [b]([a]P) + [c]P
val lemma_aff_point_mul_neg_mul_add (a b c:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg (a * b + c) p ==
S.aff_point_add (aff_point_mul_neg b (aff_point_mul_neg a p)) (aff_point_mul_neg c p))
let lemma_aff_point_mul_neg_mul_add a b c p =
lemma_aff_point_mul_neg_add (a * b) c p;
lemma_aff_point_mul_neg_mul a b p
// [a]P = [a % S.q]P
val lemma_aff_point_mul_neg_modq (a:int) (p:S.aff_point) :
Lemma (aff_point_mul_neg a p == aff_point_mul (a % S.q) p)
let lemma_aff_point_mul_neg_modq a p =
calc (==) {
aff_point_mul_neg a p;
(==) { Math.Lemmas.euclidean_division_definition a S.q }
aff_point_mul_neg (a / S.q * S.q + a % S.q) p;
(==) { lemma_aff_point_mul_neg_add (a / S.q * S.q) (a % S.q) p }
S.aff_point_add (aff_point_mul_neg (a / S.q * S.q) p) (aff_point_mul_neg (a % S.q) p);
(==) { lemma_aff_point_mul_neg_mul (a / S.q) S.q p }
S.aff_point_add
(aff_point_mul S.q (aff_point_mul_neg (a / S.q) p))
(aff_point_mul (a % S.q) p);
(==) { lemma_order_of_curve_group (aff_point_mul_neg (a / S.q) p) }
S.aff_point_add S.aff_point_at_inf (aff_point_mul (a % S.q) p);
(==) { LS.aff_point_add_comm_lemma S.aff_point_at_inf (aff_point_mul (a % S.q) p) }
S.aff_point_add (aff_point_mul (a % S.q) p) S.aff_point_at_inf;
(==) { LS.aff_point_at_inf_lemma (aff_point_mul (a % S.q) p) }
aff_point_mul (a % S.q) p;
}
// [a]P = [(-a) % q](-P)
val lemma_aff_point_mul_neg: a:S.qelem -> p:S.aff_point ->
Lemma (aff_point_mul ((- a) % S.q) (S.aff_point_negate p) == aff_point_mul a p)
let lemma_aff_point_mul_neg a p =
let cm = S.mk_k256_comm_monoid in
let ag = S.mk_k256_abelian_group in
let p_neg = S.aff_point_negate p in
if a > 0 then begin
calc (==) {
aff_point_mul ((- a) % S.q) p_neg;
(==) { lemma_aff_point_mul_neg_modq (- a) p_neg }
aff_point_mul_neg (- a) p_neg;
(==) { }
S.aff_point_negate (aff_point_mul a p_neg);
(==) { LE.lemma_inverse_pow ag p a }
S.aff_point_negate (S.aff_point_negate (aff_point_mul a p));
(==) { LE.lemma_inverse_id ag (aff_point_mul a p) }
aff_point_mul a p;
} end
else begin
LE.lemma_pow0 cm p;
LE.lemma_pow0 cm p_neg end
//--------------------------------------------
// [a]([b]P) = [b]([a]P)
val aff_point_mul_mul_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (aff_point_mul b p) == aff_point_mul b (aff_point_mul a p)) | false | false | Hacl.Spec.K256.ECSM.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val aff_point_mul_mul_lemma: a:nat -> b:nat -> p:S.aff_point ->
Lemma (aff_point_mul a (aff_point_mul b p) == aff_point_mul b (aff_point_mul a p)) | [] | Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul_mul_lemma | {
"file_name": "code/k256/Hacl.Spec.K256.ECSM.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Prims.nat -> b: Prims.nat -> p: Spec.K256.PointOps.aff_point
-> FStar.Pervasives.Lemma
(ensures
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul a (Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul b p) ==
Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul b (Hacl.Spec.K256.ECSM.Lemmas.aff_point_mul a p)) | {
"end_col": 3,
"end_line": 118,
"start_col": 2,
"start_line": 112
} |
Prims.Tot | val divides (a b: int) : prop | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let divides (a b:int) : prop = exists q. b = q * a | val divides (a b: int) : prop
let divides (a b: int) : prop = | false | null | false | exists q. b = q * a | {
"checked_file": "FStar.Math.Euclid.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Math.Euclid.fsti"
} | [
"total"
] | [
"Prims.int",
"Prims.l_Exists",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Mul.op_Star",
"Prims.prop"
] | [] | module FStar.Math.Euclid
open FStar.Mul
///
/// Divides relation
///
/// It is reflexive, transitive, and antisymmetric up to sign.
/// When a <> 0, a `divides` b iff a % b = 0 (this is proved below)
/// | false | true | FStar.Math.Euclid.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val divides (a b: int) : prop | [] | FStar.Math.Euclid.divides | {
"file_name": "ulib/FStar.Math.Euclid.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Prims.int -> b: Prims.int -> Prims.prop | {
"end_col": 50,
"end_line": 12,
"start_col": 31,
"start_line": 12
} |
Prims.Tot | val is_gcd (a b d: int) : prop | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_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_gcd (a b d:int) : prop =
d `divides` a /\
d `divides` b /\
(forall x. (x `divides` a /\ x `divides` b) ==> x `divides` d) | val is_gcd (a b d: int) : prop
let is_gcd (a b d: int) : prop = | false | null | false | d `divides` a /\ d `divides` b /\ (forall x. (x `divides` a /\ x `divides` b) ==> x `divides` d) | {
"checked_file": "FStar.Math.Euclid.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Math.Euclid.fsti"
} | [
"total"
] | [
"Prims.int",
"Prims.l_and",
"FStar.Math.Euclid.divides",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.prop"
] | [] | module FStar.Math.Euclid
open FStar.Mul
///
/// Divides relation
///
/// It is reflexive, transitive, and antisymmetric up to sign.
/// When a <> 0, a `divides` b iff a % b = 0 (this is proved below)
///
let divides (a b:int) : prop = exists q. b = q * a
val divides_reflexive (a:int) : Lemma (a `divides` a) [SMTPat (a `divides` a)]
val divides_transitive (a b c:int) : Lemma
(requires a `divides` b /\ b `divides` c)
(ensures a `divides` c)
val divide_antisym (a b:int) : Lemma
(requires a `divides` b /\ b `divides` a)
(ensures a = b \/ a = -b)
val divides_0 (a:int) : Lemma (a `divides` 0)
val divides_1 (a:int) : Lemma (requires a `divides` 1) (ensures a = 1 \/ a = -1)
val divides_minus (a b:int) : Lemma
(requires a `divides` b)
(ensures a `divides` (-b))
val divides_opp (a b:int) : Lemma
(requires a `divides` b)
(ensures (-a) `divides` b)
val divides_plus (a b d:int) : Lemma
(requires d `divides` a /\ d `divides` b)
(ensures d `divides` (a + b))
val divides_sub (a b d:int) : Lemma
(requires d `divides` a /\ d `divides` b)
(ensures d `divides` (a - b))
val divides_mult_right (a b d:int) : Lemma
(requires d `divides` b)
(ensures d `divides` (a * b))
///
/// Greatest Common Divisor (GCD) relation
///
/// We deviate from the standard definition in that we allow the divisor to
/// be negative. Thus, the GCD of two integers is unique up to sign.
/// | false | true | FStar.Math.Euclid.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_gcd (a b d: int) : prop | [] | FStar.Math.Euclid.is_gcd | {
"file_name": "ulib/FStar.Math.Euclid.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: Prims.int -> b: Prims.int -> d: Prims.int -> Prims.prop | {
"end_col": 64,
"end_line": 58,
"start_col": 2,
"start_line": 56
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_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_prime (p:int) =
1 < p /\
(forall (d:int).{:pattern (d `divides` p)}
(d `divides` p ==> (d = 1 \/ d = -1 \/ d = p \/ d = -p))) | let is_prime (p: int) = | false | null | false | 1 < p /\
(forall (d: int). {:pattern (d `divides` p)}
(d `divides` p ==> (d = 1 \/ d = - 1 \/ d = p \/ d = - p))) | {
"checked_file": "FStar.Math.Euclid.fsti.checked",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "FStar.Math.Euclid.fsti"
} | [
"total"
] | [
"Prims.int",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.Math.Euclid.divides",
"Prims.l_or",
"Prims.op_Equality",
"Prims.op_Minus",
"Prims.logical"
] | [] | module FStar.Math.Euclid
open FStar.Mul
///
/// Divides relation
///
/// It is reflexive, transitive, and antisymmetric up to sign.
/// When a <> 0, a `divides` b iff a % b = 0 (this is proved below)
///
let divides (a b:int) : prop = exists q. b = q * a
val divides_reflexive (a:int) : Lemma (a `divides` a) [SMTPat (a `divides` a)]
val divides_transitive (a b c:int) : Lemma
(requires a `divides` b /\ b `divides` c)
(ensures a `divides` c)
val divide_antisym (a b:int) : Lemma
(requires a `divides` b /\ b `divides` a)
(ensures a = b \/ a = -b)
val divides_0 (a:int) : Lemma (a `divides` 0)
val divides_1 (a:int) : Lemma (requires a `divides` 1) (ensures a = 1 \/ a = -1)
val divides_minus (a b:int) : Lemma
(requires a `divides` b)
(ensures a `divides` (-b))
val divides_opp (a b:int) : Lemma
(requires a `divides` b)
(ensures (-a) `divides` b)
val divides_plus (a b d:int) : Lemma
(requires d `divides` a /\ d `divides` b)
(ensures d `divides` (a + b))
val divides_sub (a b d:int) : Lemma
(requires d `divides` a /\ d `divides` b)
(ensures d `divides` (a - b))
val divides_mult_right (a b d:int) : Lemma
(requires d `divides` b)
(ensures d `divides` (a * b))
///
/// Greatest Common Divisor (GCD) relation
///
/// We deviate from the standard definition in that we allow the divisor to
/// be negative. Thus, the GCD of two integers is unique up to sign.
///
let is_gcd (a b d:int) : prop =
d `divides` a /\
d `divides` b /\
(forall x. (x `divides` a /\ x `divides` b) ==> x `divides` d)
val mod_divides (a:int) (b:nonzero) : Lemma (requires a % b = 0) (ensures b `divides` a)
val divides_mod (a:int) (b:nonzero) : Lemma (requires b `divides` a) (ensures a % b = 0)
val is_gcd_unique (a b c d:int) : Lemma
(requires is_gcd a b c /\ is_gcd a b d)
(ensures c = d \/ c = -d)
val is_gcd_reflexive (a:int) : Lemma (is_gcd a a a)
val is_gcd_symmetric (a b d:int) : Lemma
(requires is_gcd a b d)
(ensures is_gcd b a d)
val is_gcd_0 (a:int) : Lemma (is_gcd a 0 a)
val is_gcd_1 (a:int) : Lemma (is_gcd a 1 1)
val is_gcd_minus (a b d:int) : Lemma
(requires is_gcd a (-b) d)
(ensures is_gcd b a d)
val is_gcd_opp (a b d:int) : Lemma
(requires is_gcd a b d)
(ensures is_gcd b a (-d))
val is_gcd_plus (a b q d:int) : Lemma
(requires is_gcd a b d)
(ensures is_gcd a (b + q * a) d)
///
/// Extended Euclidean algorithm
///
/// Computes the GCD of two integers (a, b) together with Bézout coefficients
/// (r, s) satisfying r a + s b = gcd(a, b)
///
val euclid_gcd (a b:int) : Pure (int & int & int)
(requires True)
(ensures fun (r, s, d) -> r * a + s * b = d /\ is_gcd a b d)
///
/// A definition of primality based on the divides relation
/// | false | true | FStar.Math.Euclid.fsti | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val is_prime : p: Prims.int -> Prims.logical | [] | FStar.Math.Euclid.is_prime | {
"file_name": "ulib/FStar.Math.Euclid.fsti",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | p: Prims.int -> Prims.logical | {
"end_col": 62,
"end_line": 108,
"start_col": 2,
"start_line": 106
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": "MH"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Spec_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint8_p = B.buffer UInt8.t | let uint8_p = | false | null | false | B.buffer UInt8.t | {
"checked_file": "Vale.Wrapper.X64.Poly.fsti.checked",
"dependencies": [
"Vale.Poly1305.Util.fsti.checked",
"Vale.Poly1305.Spec_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Wrapper.X64.Poly.fsti"
} | [
"total"
] | [
"LowStar.Buffer.buffer",
"FStar.UInt8.t"
] | [] | module Vale.Wrapper.X64.Poly
open FStar.HyperStack.ST
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
module HS = FStar.HyperStack
open FStar.Mul
open Vale.Poly1305.Util
open Vale.Poly1305.Math
open Vale.Poly1305.Spec_s
open Vale.Def.Types_s
open Vale.Interop.Base
module MH = Vale.AsLowStar.MemoryHelpers | false | true | Vale.Wrapper.X64.Poly.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 uint8_p : Type0 | [] | Vale.Wrapper.X64.Poly.uint8_p | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.Poly.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Type0 | {
"end_col": 30,
"end_line": 17,
"start_col": 14,
"start_line": 17
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": "MH"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Spec_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint64 = UInt64.t | let uint64 = | false | null | false | UInt64.t | {
"checked_file": "Vale.Wrapper.X64.Poly.fsti.checked",
"dependencies": [
"Vale.Poly1305.Util.fsti.checked",
"Vale.Poly1305.Spec_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Wrapper.X64.Poly.fsti"
} | [
"total"
] | [
"FStar.UInt64.t"
] | [] | module Vale.Wrapper.X64.Poly
open FStar.HyperStack.ST
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
module HS = FStar.HyperStack
open FStar.Mul
open Vale.Poly1305.Util
open Vale.Poly1305.Math
open Vale.Poly1305.Spec_s
open Vale.Def.Types_s
open Vale.Interop.Base
module MH = Vale.AsLowStar.MemoryHelpers
unfold
let uint8_p = B.buffer UInt8.t | false | true | Vale.Wrapper.X64.Poly.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 uint64 : Prims.eqtype | [] | Vale.Wrapper.X64.Poly.uint64 | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.Poly.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Prims.eqtype | {
"end_col": 21,
"end_line": 19,
"start_col": 13,
"start_line": 19
} |
|
Prims.Tot | val uint64_to_nat_seq (b: Seq.seq UInt64.t) : Seq.lseq nat64 (Seq.length b) | [
{
"abbrev": true,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": "MH"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Spec_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint64_to_nat_seq
(b:Seq.seq UInt64.t)
: Seq.lseq nat64 (Seq.length b)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> (UInt64.v (Seq.index b i) <: nat64)) | val uint64_to_nat_seq (b: Seq.seq UInt64.t) : Seq.lseq nat64 (Seq.length b)
let uint64_to_nat_seq (b: Seq.seq UInt64.t) : Seq.lseq nat64 (Seq.length b) = | false | null | false | Seq.init (Seq.length b) (fun (i: nat{i < Seq.length b}) -> (UInt64.v (Seq.index b i) <: nat64)) | {
"checked_file": "Vale.Wrapper.X64.Poly.fsti.checked",
"dependencies": [
"Vale.Poly1305.Util.fsti.checked",
"Vale.Poly1305.Spec_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Wrapper.X64.Poly.fsti"
} | [
"total"
] | [
"FStar.Seq.Base.seq",
"FStar.UInt64.t",
"FStar.Seq.Base.init",
"Vale.Def.Types_s.nat64",
"FStar.Seq.Base.length",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt64.v",
"FStar.Seq.Base.index",
"FStar.Seq.Properties.lseq"
] | [] | module Vale.Wrapper.X64.Poly
open FStar.HyperStack.ST
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
module HS = FStar.HyperStack
open FStar.Mul
open Vale.Poly1305.Util
open Vale.Poly1305.Math
open Vale.Poly1305.Spec_s
open Vale.Def.Types_s
open Vale.Interop.Base
module MH = Vale.AsLowStar.MemoryHelpers
unfold
let uint8_p = B.buffer UInt8.t
unfold
let uint64 = UInt64.t
noextract
let uint64_to_nat_seq
(b:Seq.seq UInt64.t) | false | false | Vale.Wrapper.X64.Poly.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 uint64_to_nat_seq (b: Seq.seq UInt64.t) : Seq.lseq nat64 (Seq.length b) | [] | Vale.Wrapper.X64.Poly.uint64_to_nat_seq | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.Poly.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: FStar.Seq.Base.seq FStar.UInt64.t
-> FStar.Seq.Properties.lseq Vale.Def.Types_s.nat64 (FStar.Seq.Base.length b) | {
"end_col": 100,
"end_line": 25,
"start_col": 6,
"start_line": 25
} |
FStar.Pervasives.Lemma | val math_aux (b: uint8_p) (n: nat)
: Lemma (requires B.length b = 8 * n) (ensures DV.length (get_downview b) % 8 = 0) | [
{
"abbrev": true,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": "MH"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Spec_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Up",
"short_module": "UV"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let math_aux (b:uint8_p) (n:nat) : Lemma
(requires B.length b = 8 * n)
(ensures DV.length (get_downview b) % 8 = 0) =
DV.length_eq (get_downview b) | val math_aux (b: uint8_p) (n: nat)
: Lemma (requires B.length b = 8 * n) (ensures DV.length (get_downview b) % 8 = 0)
let math_aux (b: uint8_p) (n: nat)
: Lemma (requires B.length b = 8 * n) (ensures DV.length (get_downview b) % 8 = 0) = | false | null | true | DV.length_eq (get_downview b) | {
"checked_file": "Vale.Wrapper.X64.Poly.fsti.checked",
"dependencies": [
"Vale.Poly1305.Util.fsti.checked",
"Vale.Poly1305.Spec_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Interop.Views.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"prims.fst.checked",
"LowStar.BufferView.Up.fsti.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Wrapper.X64.Poly.fsti"
} | [
"lemma"
] | [
"Vale.Wrapper.X64.Poly.uint8_p",
"Prims.nat",
"LowStar.BufferView.Down.length_eq",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Arch.HeapTypes_s.TUInt8",
"LowStar.Buffer.trivial_preorder",
"Prims.unit",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"LowStar.Monotonic.Buffer.length",
"FStar.Mul.op_Star",
"Prims.squash",
"Prims.op_Modulus",
"LowStar.BufferView.Down.length",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module Vale.Wrapper.X64.Poly
open FStar.HyperStack.ST
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
module UV = LowStar.BufferView.Up
module HS = FStar.HyperStack
open FStar.Mul
open Vale.Poly1305.Util
open Vale.Poly1305.Math
open Vale.Poly1305.Spec_s
open Vale.Def.Types_s
open Vale.Interop.Base
module MH = Vale.AsLowStar.MemoryHelpers
unfold
let uint8_p = B.buffer UInt8.t
unfold
let uint64 = UInt64.t
noextract
let uint64_to_nat_seq
(b:Seq.seq UInt64.t)
: Seq.lseq nat64 (Seq.length b)
= Seq.init (Seq.length b) (fun (i:nat{i < Seq.length b}) -> (UInt64.v (Seq.index b i) <: nat64))
let math_aux (b:uint8_p) (n:nat) : Lemma
(requires B.length b = 8 * n) | false | false | Vale.Wrapper.X64.Poly.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 math_aux (b: uint8_p) (n: nat)
: Lemma (requires B.length b = 8 * n) (ensures DV.length (get_downview b) % 8 = 0) | [] | Vale.Wrapper.X64.Poly.math_aux | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.Poly.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | b: Vale.Wrapper.X64.Poly.uint8_p -> n: Prims.nat
-> FStar.Pervasives.Lemma (requires LowStar.Monotonic.Buffer.length b = 8 * n)
(ensures LowStar.BufferView.Down.length (Vale.Interop.Types.get_downview b) % 8 = 0) | {
"end_col": 31,
"end_line": 30,
"start_col": 2,
"start_line": 30
} |
Prims.GTot | val validate_list_up_to_inv
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0 | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.ListUpTo",
"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 validate_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
= let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\
live_slice h0 sl /\
B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\
U32.v pos0 <= U64.v pos /\
begin if is_success pos
then
let pos = uint64_to_uint32 pos in
U32.v pos <= U32.v sl.len /\
begin if stop
then
valid_pos q h0 sl pos0 pos
else
(valid q h0 sl pos0 <==> valid q h0 sl pos) /\
((valid q h0 sl pos0 /\ valid q h0 sl pos) ==>
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos
)
end
else
stop == true /\
(~ (valid q h0 sl pos0))
end | val validate_list_up_to_inv
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
let validate_list_up_to_inv
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0 = | false | null | false | let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\ live_slice h0 sl /\ B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\ U32.v pos0 <= U64.v pos /\
(if is_success pos
then
let pos = uint64_to_uint32 pos in
U32.v pos <= U32.v sl.len /\
(if stop
then valid_pos q h0 sl pos0 pos
else
(valid q h0 sl pos0 <==> valid q h0 sl pos) /\
((valid q h0 sl pos0 /\ valid q h0 sl pos) ==>
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos))
else stop == true /\ (~(valid q h0 sl pos0))) | {
"checked_file": "LowParse.Low.ListUpTo.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.ListUpTo.fst"
} | [
"sometrivial"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"Prims.bool",
"LowParse.Spec.ListUpTo.consumes_if_not_cond",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserConsumesAll",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Buffer.pointer",
"FStar.UInt64.t",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Buffer.trivial_preorder",
"LowParse.Slice.live_slice",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowParse.Slice.buffer_srel_of_srel",
"LowParse.Slice.__proj__Mkslice__item__base",
"LowStar.Monotonic.Buffer.modifies",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"FStar.UInt64.v",
"LowParse.Low.ErrorCode.is_success",
"LowParse.Slice.__proj__Mkslice__item__len",
"LowParse.Low.Base.Spec.valid_pos",
"LowParse.Spec.ListUpTo.parse_list_up_to_kind",
"LowParse.Spec.ListUpTo.parse_list_up_to_t",
"Prims.l_iff",
"LowParse.Low.Base.Spec.valid",
"Prims.l_imp",
"Prims.eq2",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.logical",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"Prims.l_not",
"LowParse.Spec.ListUpTo.parse_list_up_to",
"LowStar.Monotonic.Buffer.deref"
] | [] | module LowParse.Low.ListUpTo
include LowParse.Spec.ListUpTo
include LowParse.Low.Base
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
unfold
let validate_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool) | false | false | LowParse.Low.ListUpTo.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 validate_list_up_to_inv
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0 | [] | LowParse.Low.ListUpTo.validate_list_up_to_inv | {
"file_name": "src/lowparse/LowParse.Low.ListUpTo.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cond: (_: t -> Prims.bool) ->
prf:
LowParse.Spec.ListUpTo.consumes_if_not_cond cond p
{ Mkparser_kind'?.parser_kind_subkind k <>
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserConsumesAll } ->
sl: LowParse.Slice.slice rrel rel ->
pos0: FStar.UInt32.t ->
h0: FStar.Monotonic.HyperStack.mem ->
bpos: LowStar.Buffer.pointer FStar.UInt64.t ->
h: FStar.Monotonic.HyperStack.mem ->
stop: Prims.bool
-> Prims.GTot Type0 | {
"end_col": 5,
"end_line": 49,
"start_col": 1,
"start_line": 26
} |
Prims.GTot | val jump_list_up_to_inv
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
(h: HS.mem)
(stop: bool)
: GTot Type0 | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.ListUpTo",
"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 jump_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
= let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\
live_slice h0 sl /\
B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\
U32.v pos0 <= U32.v pos /\
valid q h0 sl pos0 /\
begin if stop
then
get_valid_pos q h0 sl pos0 == pos
else
valid q h0 sl pos /\
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos
end | val jump_list_up_to_inv
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
let jump_list_up_to_inv
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
(h: HS.mem)
(stop: bool)
: GTot Type0 = | false | null | false | let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\ live_slice h0 sl /\ B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\ U32.v pos0 <= U32.v pos /\ valid q h0 sl pos0 /\
(if stop
then get_valid_pos q h0 sl pos0 == pos
else valid q h0 sl pos /\ get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos) | {
"checked_file": "LowParse.Low.ListUpTo.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.ListUpTo.fst"
} | [
"sometrivial"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"Prims.bool",
"LowParse.Spec.ListUpTo.consumes_if_not_cond",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserConsumesAll",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"LowStar.Buffer.pointer",
"Prims.l_and",
"LowStar.Monotonic.Buffer.live",
"LowStar.Buffer.trivial_preorder",
"LowParse.Slice.live_slice",
"LowStar.Monotonic.Buffer.loc_disjoint",
"LowStar.Monotonic.Buffer.loc_buffer",
"LowParse.Slice.buffer_srel_of_srel",
"LowParse.Slice.__proj__Mkslice__item__base",
"LowStar.Monotonic.Buffer.modifies",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"LowParse.Low.Base.Spec.valid",
"LowParse.Spec.ListUpTo.parse_list_up_to_kind",
"LowParse.Spec.ListUpTo.parse_list_up_to_t",
"Prims.eq2",
"LowParse.Low.Base.Spec.get_valid_pos",
"Prims.logical",
"LowParse.Spec.ListUpTo.parse_list_up_to",
"LowStar.Monotonic.Buffer.deref"
] | [] | module LowParse.Low.ListUpTo
include LowParse.Spec.ListUpTo
include LowParse.Low.Base
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
unfold
let validate_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
= let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\
live_slice h0 sl /\
B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\
U32.v pos0 <= U64.v pos /\
begin if is_success pos
then
let pos = uint64_to_uint32 pos in
U32.v pos <= U32.v sl.len /\
begin if stop
then
valid_pos q h0 sl pos0 pos
else
(valid q h0 sl pos0 <==> valid q h0 sl pos) /\
((valid q h0 sl pos0 /\ valid q h0 sl pos) ==>
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos
)
end
else
stop == true /\
(~ (valid q h0 sl pos0))
end
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_list_up_to_body
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false
))
(ensures (fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop
))
=
let h = HST.get () in
let pos = B.index bpos 0ul in
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos);
parse_list_up_to_eq cond p prf (bytes_of_slice_from h sl (uint64_to_uint32 pos));
valid_facts p h sl (uint64_to_uint32 pos);
let pos1 = v sl pos in
B.upd bpos 0ul pos1;
if is_error pos1
then
true
else begin
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos1);
cond_impl sl (uint64_to_uint32 pos)
end
#pop-options
inline_for_extraction
let validate_list_up_to
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
: Tot (validator (parse_list_up_to cond p prf))
= fun #rrel #rel sl pos ->
HST.push_frame ();
let bpos = B.alloca pos 1ul in
let h2 = HST.get () in
C.Loops.do_while
(validate_list_up_to_inv cond prf sl (uint64_to_uint32 pos) h2 bpos)
(fun _ -> validate_list_up_to_body cond prf v cond_impl sl (uint64_to_uint32 pos) h2 bpos)
;
let res = B.index bpos 0ul in
HST.pop_frame ();
res
unfold
let jump_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
(h: HS.mem)
(stop: bool) | false | false | LowParse.Low.ListUpTo.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 jump_list_up_to_inv
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
(h: HS.mem)
(stop: bool)
: GTot Type0 | [] | LowParse.Low.ListUpTo.jump_list_up_to_inv | {
"file_name": "src/lowparse/LowParse.Low.ListUpTo.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cond: (_: t -> Prims.bool) ->
prf:
LowParse.Spec.ListUpTo.consumes_if_not_cond cond p
{ Mkparser_kind'?.parser_kind_subkind k <>
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserConsumesAll } ->
sl: LowParse.Slice.slice rrel rel ->
pos0: FStar.UInt32.t ->
h0: FStar.Monotonic.HyperStack.mem ->
bpos: LowStar.Buffer.pointer FStar.UInt32.t ->
h: FStar.Monotonic.HyperStack.mem ->
stop: Prims.bool
-> Prims.GTot Type0 | {
"end_col": 5,
"end_line": 168,
"start_col": 1,
"start_line": 154
} |
Prims.Tot | val jump_list_up_to
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(j: jumper p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
: Tot (jumper (parse_list_up_to cond p prf)) | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.ListUpTo",
"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 jump_list_up_to
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(j: jumper p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
: Tot (jumper (parse_list_up_to cond p prf))
= fun #rrel #rel sl pos ->
HST.push_frame ();
let bpos = B.alloca pos 1ul in
let h2 = HST.get () in
C.Loops.do_while
(jump_list_up_to_inv cond prf sl pos h2 bpos)
(fun _ -> jump_list_up_to_body cond prf j cond_impl sl pos h2 bpos)
;
let res = B.index bpos 0ul in
HST.pop_frame ();
res | val jump_list_up_to
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(j: jumper p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
: Tot (jumper (parse_list_up_to cond p prf))
let jump_list_up_to
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(j: jumper p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
: Tot (jumper (parse_list_up_to cond p prf)) = | false | null | false | fun #rrel #rel sl pos ->
HST.push_frame ();
let bpos = B.alloca pos 1ul in
let h2 = HST.get () in
C.Loops.do_while (jump_list_up_to_inv cond prf sl pos h2 bpos)
(fun _ -> jump_list_up_to_body cond prf j cond_impl sl pos h2 bpos);
let res = B.index bpos 0ul in
HST.pop_frame ();
res | {
"checked_file": "LowParse.Low.ListUpTo.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.ListUpTo.fst"
} | [
"total"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"Prims.bool",
"LowParse.Spec.ListUpTo.consumes_if_not_cond",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserConsumesAll",
"LowParse.Low.Base.jumper",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Low.Base.Spec.valid",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.eq2",
"LowParse.Low.Base.Spec.contents",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"LowStar.Monotonic.Buffer.index",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"C.Loops.do_while",
"LowParse.Low.ListUpTo.jump_list_up_to_inv",
"LowParse.Low.ListUpTo.jump_list_up_to_body",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Buffer.alloca",
"FStar.HyperStack.ST.push_frame",
"LowParse.Spec.ListUpTo.parse_list_up_to_kind",
"LowParse.Spec.ListUpTo.parse_list_up_to_t",
"LowParse.Spec.ListUpTo.parse_list_up_to"
] | [] | module LowParse.Low.ListUpTo
include LowParse.Spec.ListUpTo
include LowParse.Low.Base
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
unfold
let validate_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
= let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\
live_slice h0 sl /\
B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\
U32.v pos0 <= U64.v pos /\
begin if is_success pos
then
let pos = uint64_to_uint32 pos in
U32.v pos <= U32.v sl.len /\
begin if stop
then
valid_pos q h0 sl pos0 pos
else
(valid q h0 sl pos0 <==> valid q h0 sl pos) /\
((valid q h0 sl pos0 /\ valid q h0 sl pos) ==>
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos
)
end
else
stop == true /\
(~ (valid q h0 sl pos0))
end
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_list_up_to_body
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false
))
(ensures (fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop
))
=
let h = HST.get () in
let pos = B.index bpos 0ul in
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos);
parse_list_up_to_eq cond p prf (bytes_of_slice_from h sl (uint64_to_uint32 pos));
valid_facts p h sl (uint64_to_uint32 pos);
let pos1 = v sl pos in
B.upd bpos 0ul pos1;
if is_error pos1
then
true
else begin
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos1);
cond_impl sl (uint64_to_uint32 pos)
end
#pop-options
inline_for_extraction
let validate_list_up_to
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
: Tot (validator (parse_list_up_to cond p prf))
= fun #rrel #rel sl pos ->
HST.push_frame ();
let bpos = B.alloca pos 1ul in
let h2 = HST.get () in
C.Loops.do_while
(validate_list_up_to_inv cond prf sl (uint64_to_uint32 pos) h2 bpos)
(fun _ -> validate_list_up_to_body cond prf v cond_impl sl (uint64_to_uint32 pos) h2 bpos)
;
let res = B.index bpos 0ul in
HST.pop_frame ();
res
unfold
let jump_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
= let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\
live_slice h0 sl /\
B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\
U32.v pos0 <= U32.v pos /\
valid q h0 sl pos0 /\
begin if stop
then
get_valid_pos q h0 sl pos0 == pos
else
valid q h0 sl pos /\
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos
end
#push-options "--z3rlimit 16"
inline_for_extraction
let jump_list_up_to_body
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(j: jumper p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
: HST.Stack bool
(requires (fun h ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false
))
(ensures (fun h stop h' ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
jump_list_up_to_inv cond prf sl pos0 h0 bpos h' stop
))
=
let h = HST.get () in
let pos = B.index bpos 0ul in
valid_facts (parse_list_up_to cond p prf) h sl pos;
parse_list_up_to_eq cond p prf (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = j sl pos in
B.upd bpos 0ul pos1;
valid_facts (parse_list_up_to cond p prf) h sl pos1;
cond_impl sl pos
#pop-options
inline_for_extraction
let jump_list_up_to
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(j: jumper p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
)) | false | false | LowParse.Low.ListUpTo.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 jump_list_up_to
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(j: jumper p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
: Tot (jumper (parse_list_up_to cond p prf)) | [] | LowParse.Low.ListUpTo.jump_list_up_to | {
"file_name": "src/lowparse/LowParse.Low.ListUpTo.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cond: (_: t -> Prims.bool) ->
prf:
LowParse.Spec.ListUpTo.consumes_if_not_cond cond p
{ Mkparser_kind'?.parser_kind_subkind k <>
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserConsumesAll } ->
j: LowParse.Low.Base.jumper p ->
cond_impl:
(sl: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack Prims.bool)
-> LowParse.Low.Base.jumper (LowParse.Spec.ListUpTo.parse_list_up_to cond p prf) | {
"end_col": 5,
"end_line": 251,
"start_col": 2,
"start_line": 241
} |
Prims.Tot | val validate_list_up_to
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(v: validator p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
: Tot (validator (parse_list_up_to cond p prf)) | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.ListUpTo",
"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 validate_list_up_to
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
: Tot (validator (parse_list_up_to cond p prf))
= fun #rrel #rel sl pos ->
HST.push_frame ();
let bpos = B.alloca pos 1ul in
let h2 = HST.get () in
C.Loops.do_while
(validate_list_up_to_inv cond prf sl (uint64_to_uint32 pos) h2 bpos)
(fun _ -> validate_list_up_to_body cond prf v cond_impl sl (uint64_to_uint32 pos) h2 bpos)
;
let res = B.index bpos 0ul in
HST.pop_frame ();
res | val validate_list_up_to
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(v: validator p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
: Tot (validator (parse_list_up_to cond p prf))
let validate_list_up_to
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(v: validator p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
: Tot (validator (parse_list_up_to cond p prf)) = | false | null | false | fun #rrel #rel sl pos ->
HST.push_frame ();
let bpos = B.alloca pos 1ul in
let h2 = HST.get () in
C.Loops.do_while (validate_list_up_to_inv cond prf sl (uint64_to_uint32 pos) h2 bpos)
(fun _ -> validate_list_up_to_body cond prf v cond_impl sl (uint64_to_uint32 pos) h2 bpos);
let res = B.index bpos 0ul in
HST.pop_frame ();
res | {
"checked_file": "LowParse.Low.ListUpTo.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.ListUpTo.fst"
} | [
"total"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"Prims.bool",
"LowParse.Spec.ListUpTo.consumes_if_not_cond",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserConsumesAll",
"LowParse.Low.Base.validator",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Low.Base.Spec.valid",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.eq2",
"LowParse.Low.Base.Spec.contents",
"FStar.UInt64.t",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"LowStar.Monotonic.Buffer.index",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"C.Loops.do_while",
"LowParse.Low.ListUpTo.validate_list_up_to_inv",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"LowParse.Low.ListUpTo.validate_list_up_to_body",
"FStar.HyperStack.ST.get",
"LowStar.Monotonic.Buffer.mbuffer",
"Prims.nat",
"LowStar.Monotonic.Buffer.length",
"FStar.UInt32.v",
"FStar.UInt32.uint_to_t",
"Prims.op_Negation",
"LowStar.Monotonic.Buffer.g_is_null",
"LowStar.Buffer.alloca",
"FStar.HyperStack.ST.push_frame",
"LowParse.Spec.ListUpTo.parse_list_up_to_kind",
"LowParse.Spec.ListUpTo.parse_list_up_to_t",
"LowParse.Spec.ListUpTo.parse_list_up_to"
] | [] | module LowParse.Low.ListUpTo
include LowParse.Spec.ListUpTo
include LowParse.Low.Base
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
unfold
let validate_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
= let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\
live_slice h0 sl /\
B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\
U32.v pos0 <= U64.v pos /\
begin if is_success pos
then
let pos = uint64_to_uint32 pos in
U32.v pos <= U32.v sl.len /\
begin if stop
then
valid_pos q h0 sl pos0 pos
else
(valid q h0 sl pos0 <==> valid q h0 sl pos) /\
((valid q h0 sl pos0 /\ valid q h0 sl pos) ==>
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos
)
end
else
stop == true /\
(~ (valid q h0 sl pos0))
end
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_list_up_to_body
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false
))
(ensures (fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop
))
=
let h = HST.get () in
let pos = B.index bpos 0ul in
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos);
parse_list_up_to_eq cond p prf (bytes_of_slice_from h sl (uint64_to_uint32 pos));
valid_facts p h sl (uint64_to_uint32 pos);
let pos1 = v sl pos in
B.upd bpos 0ul pos1;
if is_error pos1
then
true
else begin
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos1);
cond_impl sl (uint64_to_uint32 pos)
end
#pop-options
inline_for_extraction
let validate_list_up_to
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
)) | false | false | LowParse.Low.ListUpTo.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 validate_list_up_to
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(v: validator p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
: Tot (validator (parse_list_up_to cond p prf)) | [] | LowParse.Low.ListUpTo.validate_list_up_to | {
"file_name": "src/lowparse/LowParse.Low.ListUpTo.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cond: (_: t -> Prims.bool) ->
prf:
LowParse.Spec.ListUpTo.consumes_if_not_cond cond p
{ Mkparser_kind'?.parser_kind_subkind k <>
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserConsumesAll } ->
v: LowParse.Low.Base.validator p ->
cond_impl:
(sl: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack Prims.bool)
-> LowParse.Low.Base.validator (LowParse.Spec.ListUpTo.parse_list_up_to cond p prf) | {
"end_col": 5,
"end_line": 137,
"start_col": 2,
"start_line": 127
} |
FStar.HyperStack.ST.Stack | val jump_list_up_to_body
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(j: jumper p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
: HST.Stack bool
(requires (fun h -> jump_list_up_to_inv cond prf sl pos0 h0 bpos h false))
(ensures
(fun h stop h' ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
jump_list_up_to_inv cond prf sl pos0 h0 bpos h' stop)) | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.ListUpTo",
"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 jump_list_up_to_body
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(j: jumper p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
: HST.Stack bool
(requires (fun h ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false
))
(ensures (fun h stop h' ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
jump_list_up_to_inv cond prf sl pos0 h0 bpos h' stop
))
=
let h = HST.get () in
let pos = B.index bpos 0ul in
valid_facts (parse_list_up_to cond p prf) h sl pos;
parse_list_up_to_eq cond p prf (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = j sl pos in
B.upd bpos 0ul pos1;
valid_facts (parse_list_up_to cond p prf) h sl pos1;
cond_impl sl pos | val jump_list_up_to_body
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(j: jumper p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
: HST.Stack bool
(requires (fun h -> jump_list_up_to_inv cond prf sl pos0 h0 bpos h false))
(ensures
(fun h stop h' ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
jump_list_up_to_inv cond prf sl pos0 h0 bpos h' stop))
let jump_list_up_to_body
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(j: jumper p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
: HST.Stack bool
(requires (fun h -> jump_list_up_to_inv cond prf sl pos0 h0 bpos h false))
(ensures
(fun h stop h' ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
jump_list_up_to_inv cond prf sl pos0 h0 bpos h' stop)) = | true | null | false | let h = HST.get () in
let pos = B.index bpos 0ul in
valid_facts (parse_list_up_to cond p prf) h sl pos;
parse_list_up_to_eq cond p prf (bytes_of_slice_from h sl pos);
valid_facts p h sl pos;
let pos1 = j sl pos in
B.upd bpos 0ul pos1;
valid_facts (parse_list_up_to cond p prf) h sl pos1;
cond_impl sl pos | {
"checked_file": "LowParse.Low.ListUpTo.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.ListUpTo.fst"
} | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"Prims.bool",
"LowParse.Spec.ListUpTo.consumes_if_not_cond",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserConsumesAll",
"LowParse.Low.Base.jumper",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Low.Base.Spec.valid",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.eq2",
"LowParse.Low.Base.Spec.contents",
"LowStar.Buffer.pointer",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.ListUpTo.parse_list_up_to_kind",
"LowParse.Spec.ListUpTo.parse_list_up_to_t",
"LowParse.Spec.ListUpTo.parse_list_up_to",
"LowStar.Monotonic.Buffer.upd",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"LowParse.Spec.ListUpTo.parse_list_up_to_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowStar.Monotonic.Buffer.index",
"FStar.HyperStack.ST.get",
"LowParse.Low.ListUpTo.jump_list_up_to_inv"
] | [] | module LowParse.Low.ListUpTo
include LowParse.Spec.ListUpTo
include LowParse.Low.Base
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
unfold
let validate_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
= let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\
live_slice h0 sl /\
B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\
U32.v pos0 <= U64.v pos /\
begin if is_success pos
then
let pos = uint64_to_uint32 pos in
U32.v pos <= U32.v sl.len /\
begin if stop
then
valid_pos q h0 sl pos0 pos
else
(valid q h0 sl pos0 <==> valid q h0 sl pos) /\
((valid q h0 sl pos0 /\ valid q h0 sl pos) ==>
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos
)
end
else
stop == true /\
(~ (valid q h0 sl pos0))
end
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_list_up_to_body
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false
))
(ensures (fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop
))
=
let h = HST.get () in
let pos = B.index bpos 0ul in
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos);
parse_list_up_to_eq cond p prf (bytes_of_slice_from h sl (uint64_to_uint32 pos));
valid_facts p h sl (uint64_to_uint32 pos);
let pos1 = v sl pos in
B.upd bpos 0ul pos1;
if is_error pos1
then
true
else begin
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos1);
cond_impl sl (uint64_to_uint32 pos)
end
#pop-options
inline_for_extraction
let validate_list_up_to
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
: Tot (validator (parse_list_up_to cond p prf))
= fun #rrel #rel sl pos ->
HST.push_frame ();
let bpos = B.alloca pos 1ul in
let h2 = HST.get () in
C.Loops.do_while
(validate_list_up_to_inv cond prf sl (uint64_to_uint32 pos) h2 bpos)
(fun _ -> validate_list_up_to_body cond prf v cond_impl sl (uint64_to_uint32 pos) h2 bpos)
;
let res = B.index bpos 0ul in
HST.pop_frame ();
res
unfold
let jump_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
= let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\
live_slice h0 sl /\
B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\
U32.v pos0 <= U32.v pos /\
valid q h0 sl pos0 /\
begin if stop
then
get_valid_pos q h0 sl pos0 == pos
else
valid q h0 sl pos /\
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos
end
#push-options "--z3rlimit 16"
inline_for_extraction
let jump_list_up_to_body
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(j: jumper p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
: HST.Stack bool
(requires (fun h ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false
))
(ensures (fun h stop h' ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
jump_list_up_to_inv cond prf sl pos0 h0 bpos h' stop | false | false | LowParse.Low.ListUpTo.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val jump_list_up_to_body
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(j: jumper p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U32.t)
: HST.Stack bool
(requires (fun h -> jump_list_up_to_inv cond prf sl pos0 h0 bpos h false))
(ensures
(fun h stop h' ->
jump_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
jump_list_up_to_inv cond prf sl pos0 h0 bpos h' stop)) | [] | LowParse.Low.ListUpTo.jump_list_up_to_body | {
"file_name": "src/lowparse/LowParse.Low.ListUpTo.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cond: (_: t -> Prims.bool) ->
prf:
LowParse.Spec.ListUpTo.consumes_if_not_cond cond p
{ Mkparser_kind'?.parser_kind_subkind k <>
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserConsumesAll } ->
j: LowParse.Low.Base.jumper p ->
cond_impl:
(sl: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack Prims.bool) ->
sl: LowParse.Slice.slice rrel rel ->
pos0: FStar.UInt32.t ->
h0: FStar.Monotonic.HyperStack.mem ->
bpos: LowStar.Buffer.pointer FStar.UInt32.t
-> FStar.HyperStack.ST.Stack Prims.bool | {
"end_col": 18,
"end_line": 215,
"start_col": 1,
"start_line": 206
} |
FStar.HyperStack.ST.Stack | val validate_list_up_to_body
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(v: validator p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h -> validate_list_up_to_inv cond prf sl pos0 h0 bpos h false))
(ensures
(fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop)) | [
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "U64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": false,
"full_module": "LowParse.Low.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.ListUpTo",
"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 validate_list_up_to_body
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false
))
(ensures (fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop
))
=
let h = HST.get () in
let pos = B.index bpos 0ul in
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos);
parse_list_up_to_eq cond p prf (bytes_of_slice_from h sl (uint64_to_uint32 pos));
valid_facts p h sl (uint64_to_uint32 pos);
let pos1 = v sl pos in
B.upd bpos 0ul pos1;
if is_error pos1
then
true
else begin
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos1);
cond_impl sl (uint64_to_uint32 pos)
end | val validate_list_up_to_body
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(v: validator p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h -> validate_list_up_to_inv cond prf sl pos0 h0 bpos h false))
(ensures
(fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop))
let validate_list_up_to_body
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(v: validator p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h -> validate_list_up_to_inv cond prf sl pos0 h0 bpos h false))
(ensures
(fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop)) = | true | null | false | let h = HST.get () in
let pos = B.index bpos 0ul in
valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos);
parse_list_up_to_eq cond p prf (bytes_of_slice_from h sl (uint64_to_uint32 pos));
valid_facts p h sl (uint64_to_uint32 pos);
let pos1 = v sl pos in
B.upd bpos 0ul pos1;
if is_error pos1
then true
else
(valid_facts (parse_list_up_to cond p prf) h sl (uint64_to_uint32 pos1);
cond_impl sl (uint64_to_uint32 pos)) | {
"checked_file": "LowParse.Low.ListUpTo.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"LowParse.Spec.ListUpTo.fsti.checked",
"LowParse.Low.Base.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"C.Loops.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.Low.ListUpTo.fst"
} | [] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"Prims.bool",
"LowParse.Spec.ListUpTo.consumes_if_not_cond",
"Prims.b2t",
"Prims.op_disEquality",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.ParserConsumesAll",
"LowParse.Low.Base.validator",
"LowParse.Slice.srel",
"LowParse.Bytes.byte",
"LowParse.Slice.slice",
"FStar.UInt32.t",
"FStar.Monotonic.HyperStack.mem",
"LowParse.Low.Base.Spec.valid",
"Prims.l_and",
"LowStar.Monotonic.Buffer.modifies",
"LowStar.Monotonic.Buffer.loc_none",
"Prims.eq2",
"LowParse.Low.Base.Spec.contents",
"LowStar.Buffer.pointer",
"FStar.UInt64.t",
"LowParse.Low.ErrorCode.is_error",
"LowParse.Low.ErrorCode.uint64_to_uint32",
"Prims.unit",
"LowParse.Low.Base.Spec.valid_facts",
"LowParse.Spec.ListUpTo.parse_list_up_to_kind",
"LowParse.Spec.ListUpTo.parse_list_up_to_t",
"LowParse.Spec.ListUpTo.parse_list_up_to",
"LowStar.Monotonic.Buffer.upd",
"LowStar.Buffer.trivial_preorder",
"FStar.UInt32.__uint_to_t",
"LowParse.Spec.ListUpTo.parse_list_up_to_eq",
"LowParse.Slice.bytes_of_slice_from",
"LowStar.Monotonic.Buffer.index",
"FStar.HyperStack.ST.get",
"LowParse.Low.ListUpTo.validate_list_up_to_inv"
] | [] | module LowParse.Low.ListUpTo
include LowParse.Spec.ListUpTo
include LowParse.Low.Base
module U32 = FStar.UInt32
module U64 = FStar.UInt64
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module B = LowStar.Buffer
unfold
let validate_list_up_to_inv
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
(h: HS.mem)
(stop: bool)
: GTot Type0
= let pos = B.deref h bpos in
let q = parse_list_up_to cond p prf in
B.live h0 bpos /\
live_slice h0 sl /\
B.loc_disjoint (B.loc_buffer sl.base) (B.loc_buffer bpos) /\
B.modifies (B.loc_buffer bpos) h0 h /\
U32.v pos0 <= U64.v pos /\
begin if is_success pos
then
let pos = uint64_to_uint32 pos in
U32.v pos <= U32.v sl.len /\
begin if stop
then
valid_pos q h0 sl pos0 pos
else
(valid q h0 sl pos0 <==> valid q h0 sl pos) /\
((valid q h0 sl pos0 /\ valid q h0 sl pos) ==>
get_valid_pos q h0 sl pos0 == get_valid_pos q h0 sl pos
)
end
else
stop == true /\
(~ (valid q h0 sl pos0))
end
#push-options "--z3rlimit 16"
inline_for_extraction
let validate_list_up_to_body
(#k: _)
(#t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p { k.parser_kind_subkind <> Some ParserConsumesAll } )
(v: validator p)
(cond_impl: (
(#rrel: _) ->
(#rel: _) ->
(sl: slice rrel rel) ->
(pos: U32.t) ->
HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures (fun h res h' ->
B.modifies B.loc_none h h' /\
valid p h sl pos /\
res == cond (contents p h sl pos)
))
))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false
))
(ensures (fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop | false | false | LowParse.Low.ListUpTo.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val validate_list_up_to_body
(#k #t: _)
(#p: parser k t)
(cond: (t -> Tot bool))
(prf: consumes_if_not_cond cond p {k.parser_kind_subkind <> Some ParserConsumesAll})
(v: validator p)
(cond_impl:
(#rrel: _ -> #rel: _ -> sl: slice rrel rel -> pos: U32.t
-> HST.Stack bool
(requires (fun h -> valid p h sl pos))
(ensures
(fun h res h' ->
B.modifies B.loc_none h h' /\ valid p h sl pos /\
res == cond (contents p h sl pos)))))
(#rrel #rel: _)
(sl: slice rrel rel)
(pos0: U32.t)
(h0: HS.mem)
(bpos: B.pointer U64.t)
: HST.Stack bool
(requires (fun h -> validate_list_up_to_inv cond prf sl pos0 h0 bpos h false))
(ensures
(fun h stop h' ->
validate_list_up_to_inv cond prf sl pos0 h0 bpos h false /\
validate_list_up_to_inv cond prf sl pos0 h0 bpos h' stop)) | [] | LowParse.Low.ListUpTo.validate_list_up_to_body | {
"file_name": "src/lowparse/LowParse.Low.ListUpTo.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
cond: (_: t -> Prims.bool) ->
prf:
LowParse.Spec.ListUpTo.consumes_if_not_cond cond p
{ Mkparser_kind'?.parser_kind_subkind k <>
FStar.Pervasives.Native.Some LowParse.Spec.Base.ParserConsumesAll } ->
v: LowParse.Low.Base.validator p ->
cond_impl:
(sl: LowParse.Slice.slice rrel rel -> pos: FStar.UInt32.t
-> FStar.HyperStack.ST.Stack Prims.bool) ->
sl: LowParse.Slice.slice rrel rel ->
pos0: FStar.UInt32.t ->
h0: FStar.Monotonic.HyperStack.mem ->
bpos: LowStar.Buffer.pointer FStar.UInt64.t
-> FStar.HyperStack.ST.Stack Prims.bool | {
"end_col": 5,
"end_line": 101,
"start_col": 1,
"start_line": 87
} |
FStar.Pervasives.Lemma | val lemma_aff_is_point_at_inf: p:proj_point ->
Lemma (let px, py, pz = p in
is_aff_point_at_inf (to_aff_point p) == (pz = 0 || (px = 0 && py = 0))) | [
{
"abbrev": true,
"full_module": "Lib.NatMod",
"short_module": "M"
},
{
"abbrev": false,
"full_module": "Spec.P256.PointOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.P256.PointOps",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lemma_aff_is_point_at_inf p =
prime_lemma ();
let (px, py, pz) = p in
M.lemma_div_mod_prime_is_zero #prime px pz;
M.lemma_div_mod_prime_is_zero #prime py pz | val lemma_aff_is_point_at_inf: p:proj_point ->
Lemma (let px, py, pz = p in
is_aff_point_at_inf (to_aff_point p) == (pz = 0 || (px = 0 && py = 0)))
let lemma_aff_is_point_at_inf p = | false | null | true | prime_lemma ();
let px, py, pz = p in
M.lemma_div_mod_prime_is_zero #prime px pz;
M.lemma_div_mod_prime_is_zero #prime py pz | {
"checked_file": "Spec.P256.Lemmas.fst.checked",
"dependencies": [
"Spec.P256.PointOps.fst.checked",
"prims.fst.checked",
"Lib.NatMod.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": true,
"source_file": "Spec.P256.Lemmas.fst"
} | [
"lemma"
] | [
"Spec.P256.PointOps.proj_point",
"Prims.nat",
"Lib.NatMod.lemma_div_mod_prime_is_zero",
"Spec.P256.PointOps.prime",
"Prims.unit",
"Spec.P256.Lemmas.prime_lemma"
] | [] | module Spec.P256.Lemmas
open FStar.Mul
open Spec.P256.PointOps
module M = Lib.NatMod
#set-options "--z3rlimit 50 --ifuel 0 --fuel 0"
let prime_lemma () = admit() | false | false | Spec.P256.Lemmas.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lemma_aff_is_point_at_inf: p:proj_point ->
Lemma (let px, py, pz = p in
is_aff_point_at_inf (to_aff_point p) == (pz = 0 || (px = 0 && py = 0))) | [] | Spec.P256.Lemmas.lemma_aff_is_point_at_inf | {
"file_name": "specs/lemmas/Spec.P256.Lemmas.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | p: Spec.P256.PointOps.proj_point
-> FStar.Pervasives.Lemma
(ensures
(let _ = p in
(let FStar.Pervasives.Native.Mktuple3 #_ #_ #_ px py pz = _ in
Spec.P256.PointOps.is_aff_point_at_inf (Spec.P256.PointOps.to_aff_point p) ==
(pz = 0 || px = 0 && py = 0))
<:
Type0)) | {
"end_col": 44,
"end_line": 16,
"start_col": 2,
"start_line": 13
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let post_hint_compatible (p:option post_hint_t) (x:var) (t:term) (u:universe) (post:vprop) =
match p with
| None -> True
| Some p ->
p.post== close_term post x /\
p.u == u /\
p.ret_ty == t | let post_hint_compatible (p: option post_hint_t) (x: var) (t: term) (u: universe) (post: vprop) = | false | null | false | match p with
| None -> True
| Some p -> p.post == close_term post x /\ p.u == u /\ p.ret_ty == t | {
"checked_file": "Pulse.Checker.Admit.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Admit.fst"
} | [
"total"
] | [
"FStar.Pervasives.Native.option",
"Pulse.Typing.post_hint_t",
"Pulse.Syntax.Base.var",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.vprop",
"Prims.l_True",
"Prims.l_and",
"Prims.eq2",
"Pulse.Typing.__proj__Mkpost_hint_t__item__post",
"Pulse.Syntax.Naming.close_term",
"Pulse.Typing.__proj__Mkpost_hint_t__item__u",
"Pulse.Typing.__proj__Mkpost_hint_t__item__ret_ty",
"Prims.logical"
] | [] | module Pulse.Checker.Admit
module T = FStar.Tactics.V2
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
open Pulse.Checker.Base
open Pulse.Checker.Prover
module P = Pulse.Syntax.Printer | false | true | Pulse.Checker.Admit.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 post_hint_compatible : p: FStar.Pervasives.Native.option Pulse.Typing.post_hint_t ->
x: Pulse.Syntax.Base.var ->
t: Pulse.Syntax.Base.term ->
u8: Pulse.Syntax.Base.universe ->
post: Pulse.Syntax.Base.vprop
-> Prims.logical | [] | Pulse.Checker.Admit.post_hint_compatible | {
"file_name": "lib/steel/pulse/Pulse.Checker.Admit.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
p: FStar.Pervasives.Native.option Pulse.Typing.post_hint_t ->
x: Pulse.Syntax.Base.var ->
t: Pulse.Syntax.Base.term ->
u8: Pulse.Syntax.Base.universe ->
post: Pulse.Syntax.Base.vprop
-> Prims.logical | {
"end_col": 17,
"end_line": 19,
"start_col": 2,
"start_line": 14
} |
|
FStar.Tactics.Effect.Tac | val check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term { Tm_Admit? t.term })
: T.Tac (checker_result_t g pre post_hint) | [
{
"abbrev": true,
"full_module": "Pulse.Syntax.Printer",
"short_module": "P"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Prover",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Checker",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term { Tm_Admit? t.term })
: T.Tac (checker_result_t g pre post_hint)
= let Tm_Admit r = t.term in
match post_hint with
| Some { ctag_hint=Some ct } ->
check_core g pre pre_typing post_hint res_ppname ({ t with term=Tm_Admit {r with ctag=ct}})
| _ ->
check_core g pre pre_typing post_hint res_ppname t | val check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term { Tm_Admit? t.term })
: T.Tac (checker_result_t g pre post_hint)
let check
(g: env)
(pre: term)
(pre_typing: tot_typing g pre tm_vprop)
(post_hint: post_hint_opt g)
(res_ppname: ppname)
(t: st_term{Tm_Admit? t.term})
: T.Tac (checker_result_t g pre post_hint) = | true | null | false | let Tm_Admit r = t.term in
match post_hint with
| Some { ctag_hint = Some ct } ->
check_core g
pre
pre_typing
post_hint
res_ppname
({ t with term = Tm_Admit ({ r with ctag = ct }) })
| _ -> check_core g pre pre_typing post_hint res_ppname t | {
"checked_file": "Pulse.Checker.Admit.fst.checked",
"dependencies": [
"Pulse.Typing.Env.fsti.checked",
"Pulse.Typing.fst.checked",
"Pulse.Syntax.Printer.fsti.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Checker.Pure.fsti.checked",
"Pulse.Checker.Prover.fsti.checked",
"Pulse.Checker.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Checker.Admit.fst"
} | [] | [
"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",
"Prims.b2t",
"Pulse.Syntax.Base.uu___is_Tm_Admit",
"Pulse.Syntax.Base.__proj__Mkst_term__item__term",
"Pulse.Syntax.Base.st_term'__Tm_Admit__payload",
"Pulse.Syntax.Base.ctag",
"Pulse.Syntax.Base.universe",
"Pulse.Typing.universe_of",
"FStar.Ghost.erased",
"FStar.Reflection.Typing.tot_typing",
"Pulse.Typing.elab_env",
"FStar.Reflection.Typing.mk_abs",
"Pulse.Elaborate.Pure.elab_term",
"FStar.Reflection.V2.Data.Q_Explicit",
"FStar.Reflection.Typing.mk_arrow",
"Pulse.Checker.Admit.check_core",
"Pulse.Syntax.Base.Mkst_term",
"Pulse.Syntax.Base.Tm_Admit",
"Pulse.Syntax.Base.Mkst_term'__Tm_Admit__payload",
"Pulse.Syntax.Base.__proj__Mkst_term'__Tm_Admit__payload__item__u",
"Pulse.Syntax.Base.__proj__Mkst_term'__Tm_Admit__payload__item__typ",
"Pulse.Syntax.Base.__proj__Mkst_term'__Tm_Admit__payload__item__post",
"Pulse.Syntax.Base.__proj__Mkst_term__item__range",
"Pulse.Syntax.Base.__proj__Mkst_term__item__effect_tag",
"Pulse.Checker.Base.checker_result_t",
"FStar.Pervasives.Native.option",
"Pulse.Typing.post_hint_t",
"Pulse.Syntax.Base.st_term'"
] | [] | module Pulse.Checker.Admit
module T = FStar.Tactics.V2
open Pulse.Syntax
open Pulse.Typing
open Pulse.Checker.Pure
open Pulse.Checker.Base
open Pulse.Checker.Prover
module P = Pulse.Syntax.Printer
let post_hint_compatible (p:option post_hint_t) (x:var) (t:term) (u:universe) (post:vprop) =
match p with
| None -> True
| Some p ->
p.post== close_term post x /\
p.u == u /\
p.ret_ty == t
let check_core
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term { Tm_Admit? t.term })
: T.Tac (checker_result_t g pre post_hint) =
let g = Pulse.Typing.Env.push_context g "check_admit" t.range in
let Tm_Admit { ctag = c; typ=t; post } = t.term in
let x = fresh g in
let px = v_as_nv x in
let res
: (t:term &
u:universe &
universe_of g t u &
post:vprop { post_hint_compatible post_hint x t u post } &
tot_typing (push_binding g x (fst px) t) post tm_vprop)
= match post, post_hint with
| None, None ->
fail g None "could not find a post annotation on admit, please add one"
| Some post1, Some post2 ->
fail g None
(Printf.sprintf "found two post annotations on admit: %s and %s, please remove one"
(P.term_to_string post1)
(P.term_to_string post2.post))
| Some post, _ ->
let (| u, t_typing |) = check_universe g t in
let post_opened = open_term_nv post px in
let (| post, post_typing |) =
check_tot_term_with_expected_type (push_binding g x (fst px) t) post_opened tm_vprop
in
(| t, u, t_typing, post, post_typing |)
| _, Some post ->
let post : post_hint_t = post in
if x `Set.mem` freevars post.post
then fail g None "Impossible: unexpected freevar clash in Tm_Admit, please file a bug-report"
else (
let post_typing_rec = post_hint_typing g post x in
let post_opened = open_term_nv post.post px in
assume (close_term post_opened x == post.post);
(| post.ret_ty, post.u, post_typing_rec.ty_typing, post_opened, post_typing_rec.post_typing |)
)
in
let (| t, u, t_typing, post_opened, post_typing |) = res in
let post = close_term post_opened x in
let s : st_comp = {u;res=t;pre;post} in
assume (open_term (close_term post_opened x) x == post_opened);
let d = T_Admit _ _ c (STC _ s x t_typing pre_typing post_typing) in
prove_post_hint (try_frame_pre pre_typing (match_comp_res_with_post_hint d post_hint) res_ppname) post_hint t.range
let check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term { Tm_Admit? t.term }) | false | false | Pulse.Checker.Admit.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 check
(g:env)
(pre:term)
(pre_typing:tot_typing g pre tm_vprop)
(post_hint:post_hint_opt g)
(res_ppname:ppname)
(t:st_term { Tm_Admit? t.term })
: T.Tac (checker_result_t g pre post_hint) | [] | Pulse.Checker.Admit.check | {
"file_name": "lib/steel/pulse/Pulse.Checker.Admit.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
g: Pulse.Typing.Env.env ->
pre: Pulse.Syntax.Base.term ->
pre_typing: Pulse.Typing.tot_typing g pre Pulse.Syntax.Base.tm_vprop ->
post_hint: Pulse.Typing.post_hint_opt g ->
res_ppname: Pulse.Syntax.Base.ppname ->
t: Pulse.Syntax.Base.st_term{Tm_Admit? (Mkst_term?.term t)}
-> FStar.Tactics.Effect.Tac (Pulse.Checker.Base.checker_result_t g pre post_hint) | {
"end_col": 56,
"end_line": 94,
"start_col": 3,
"start_line": 89
} |
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_BE_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Two_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.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 bytes_to_quad_size (num_bytes:nat) =
((num_bytes + 15) / 16) | let bytes_to_quad_size (num_bytes: nat) = | false | null | false | ((num_bytes + 15) / 16) | {
"checked_file": "Vale.AES.GCM_helpers_BE.fsti.checked",
"dependencies": [
"Vale.Lib.Seqs.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Two_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.AES.GCTR_BE_s.fst.checked",
"Vale.AES.AES_BE_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Vale.AES.GCM_helpers_BE.fsti"
} | [
"total"
] | [
"Prims.nat",
"Prims.op_Division",
"Prims.op_Addition",
"Prims.int"
] | [] | module Vale.AES.GCM_helpers_BE
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Words.Two_s
open Vale.Def.Words.Four_s
open Vale.Def.Types_s
open Vale.Arch.Types
open FStar.Mul
open FStar.Seq
open Vale.AES.AES_BE_s
open Vale.AES.GCTR_BE_s
open FStar.Math.Lemmas
open Vale.Lib.Seqs | false | true | Vale.AES.GCM_helpers_BE.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 bytes_to_quad_size : num_bytes: Prims.nat -> Prims.int | [] | Vale.AES.GCM_helpers_BE.bytes_to_quad_size | {
"file_name": "vale/code/crypto/aes/Vale.AES.GCM_helpers_BE.fsti",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | num_bytes: Prims.nat -> Prims.int | {
"end_col": 25,
"end_line": 17,
"start_col": 2,
"start_line": 17
} |
|
FStar.HyperStack.ST.Stack | val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true)) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_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 do_while inv f =
if not (f ()) then
do_while inv f | val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f = | true | null | false | if not (f ()) then do_while inv f | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Prims.bool",
"Prims.unit",
"Prims.l_and",
"C.Compat.Loops.do_while",
"Prims.op_Negation"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true)) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true)) | [
"recursion"
] | C.Compat.Loops.do_while | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
inv: (_: FStar.Monotonic.HyperStack.mem -> _: Prims.bool -> Prims.GTot Type0) ->
f: (_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.bool)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 18,
"end_line": 145,
"start_col": 2,
"start_line": 144
} |
FStar.HyperStack.ST.Stack | val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1)) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_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 while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end | val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body = | true | null | false | if test ()
then
(body ();
while #test_pre #test_post test body) | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.Monotonic.HyperStack.mem",
"Prims.bool",
"Prims.unit",
"C.Compat.Loops.while"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1)) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1)) | [
"recursion"
] | C.Compat.Loops.while | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
$test: (_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.bool) ->
body: (_: Prims.unit -> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 5,
"end_line": 169,
"start_col": 2,
"start_line": 166
} |
Prims.Pure | val total_while_gen
(#t: Type)
(#a: (t -> Type))
(tmes: (x: t -> GTot (a x)))
(tinv: (bool -> t -> GTot Type0))
(tcontinue: (t -> Tot bool))
(body:
(x: t
-> Pure t
(requires (tinv true x))
(ensures
(fun y ->
tinv (tcontinue y) y /\ (if tcontinue y then tmes y << tmes x else True)))))
(x: t)
: Pure t (requires (tinv true x)) (ensures (fun y -> tinv false y)) (decreases (tmes x)) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_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 total_while_gen
(#t: Type)
(#a:t -> Type)
(tmes: (x:t -> GTot (a x)))
(tinv: (bool -> t -> GTot Type0))
(tcontinue: (t -> Tot bool))
(body:
(x: t) ->
Pure t
(requires (tinv true x))
(ensures (fun y ->
tinv (tcontinue y) y /\ (
if tcontinue y then tmes y << tmes x else True)
)))
(x: t)
: Pure t
(requires (tinv true x))
(ensures (fun y -> tinv false y))
(decreases (tmes x))
= let y = body x in
let continue = tcontinue y in
if continue
then total_while_gen tmes tinv tcontinue body y
else y | val total_while_gen
(#t: Type)
(#a: (t -> Type))
(tmes: (x: t -> GTot (a x)))
(tinv: (bool -> t -> GTot Type0))
(tcontinue: (t -> Tot bool))
(body:
(x: t
-> Pure t
(requires (tinv true x))
(ensures
(fun y ->
tinv (tcontinue y) y /\ (if tcontinue y then tmes y << tmes x else True)))))
(x: t)
: Pure t (requires (tinv true x)) (ensures (fun y -> tinv false y)) (decreases (tmes x))
let rec total_while_gen
(#t: Type)
(#a: (t -> Type))
(tmes: (x: t -> GTot (a x)))
(tinv: (bool -> t -> GTot Type0))
(tcontinue: (t -> Tot bool))
(body:
(x: t
-> Pure t
(requires (tinv true x))
(ensures
(fun y ->
tinv (tcontinue y) y /\ (if tcontinue y then tmes y << tmes x else True)))))
(x: t)
: Pure t (requires (tinv true x)) (ensures (fun y -> tinv false y)) (decreases (tmes x)) = | false | null | false | let y = body x in
let continue = tcontinue y in
if continue then total_while_gen tmes tinv tcontinue body y else y | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [
""
] | [
"Prims.bool",
"Prims.l_and",
"Prims.precedes",
"Prims.l_True",
"Prims.logical",
"C.Compat.Loops.total_while_gen"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end
(* To be extracted as:
int i = <start>;
bool b = false;
for (; (!b) && (i != <end>); --i) {
b = <f> i;
}
// i and b must be in scope after the loop
*)
val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_reverse_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start -^ 1ul) in
if f start
then (start', true)
else interruptible_reverse_for start' finish inv f
(* Non-primitive combinators that can be expressed in terms of the above ******)
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in[i]);
*)
inline_for_extraction
val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) ))
inline_for_extraction
let map #a #b output input l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 input /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 input j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = input.(i) in
output.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map f (as_seq h0 input))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let map2 #a #b #c output in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 in1 /\ live h1 in2 /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
output.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* b[i] = <f>(b[i]);
*)
inline_for_extraction
val in_place_map:
#a:Type0 ->
b: buffer a ->
l: UInt32.t{ UInt32.v l = Buffer.length b } ->
f:(a -> Tot a) ->
Stack unit
(requires (fun h -> live h b))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_2 b /\ live h_1 b
/\ (let s1 = as_seq h_1 b in
let s2 = as_seq h_2 b in
s2 == seq_map f s1) ))
inline_for_extraction
let in_place_map #a b l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 b j == get h0 b j)
/\ (forall (j:nat). j < i ==> get h1 b j == f (get h0 b j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = b.(i) in
b.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 b) (seq_map f (as_seq h0 b))
(** Extracts as (destination buffer comes first):
* for (int i = 0; i < <l>; ++i)
* in1[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val in_place_map2:
#a:Type0 -> #b:Type0 ->
in1: buffer a ->
in2: buffer b{disjoint in1 in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length in1 /\ UInt32.v l = Buffer.length in2} ->
f:(a -> b -> Tot a) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2))
(ensures (fun h_1 r h_2 -> modifies_1 in1 h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 in1 in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let in_place_map2 #a #b in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 in1 /\ live h1 in2 /\ modifies_1 in1 h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 in1 j == get h0 in1 j)
/\ (forall (j:nat). j < i ==> get h1 in1 j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
in1.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 in1) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
#reset-options "--initial_fuel 2 --max_fuel 2 --z3rlimit 20"
(* Repeating the same operation a number of times over a buffer ***************)
#reset-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** To be extracted as:
* for (int i = 0; i < n; ++i)
* f(b[i]);
*)
inline_for_extraction
val repeat:
#a:Type0 ->
l: UInt32.t ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
max:UInt32.t ->
fc:(b:buffer a{length b = UInt32.v l} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0)))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_spec (UInt32.v max) f s) ))
inline_for_extraction
let repeat #a l f b max fc =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v max
/\ as_seq h1 b == repeat_spec i f (as_seq h0 b)
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v max ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
fc b;
lemma_repeat (UInt32.v i + 1) f (as_seq h0 b)
in
lemma_repeat_0 0 f (as_seq h0 b);
for 0ul max inv f'
(** To be extracted as:
* for (int i = min; i < max; ++i)
* f(b[i], i);
*)
inline_for_extraction
val repeat_range:
#a:Type0 ->
l: UInt32.t ->
min:UInt32.t ->
max:UInt32.t{UInt32.v min <= UInt32.v max} ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> i:nat{i < UInt32.v max} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
fc:(b:buffer a{length b = UInt32.v l} -> i:UInt32.t{UInt32.v i < UInt32.v max} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0 (UInt32.v i))))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_range_spec (UInt32.v min) (UInt32.v max) f s) ))
inline_for_extraction
let repeat_range #a l min max f b fc =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v max /\ UInt32.v min <= i
/\ as_seq h1 b == repeat_range_spec (UInt32.v min) i f (as_seq h0 b)
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v max ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
fc b i;
lemma_repeat_range_spec (UInt32.v min) (UInt32.v i + 1) f (as_seq h0 b)
in
lemma_repeat_range_0 (UInt32.v min) f (as_seq h0 b);
for min max inv f'
let rec total_while_gen
(#t: Type)
(#a:t -> Type)
(tmes: (x:t -> GTot (a x)))
(tinv: (bool -> t -> GTot Type0))
(tcontinue: (t -> Tot bool))
(body:
(x: t) ->
Pure t
(requires (tinv true x))
(ensures (fun y ->
tinv (tcontinue y) y /\ (
if tcontinue y then tmes y << tmes x else True)
)))
(x: t)
: Pure t
(requires (tinv true x))
(ensures (fun y -> tinv false y)) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val total_while_gen
(#t: Type)
(#a: (t -> Type))
(tmes: (x: t -> GTot (a x)))
(tinv: (bool -> t -> GTot Type0))
(tcontinue: (t -> Tot bool))
(body:
(x: t
-> Pure t
(requires (tinv true x))
(ensures
(fun y ->
tinv (tcontinue y) y /\ (if tcontinue y then tmes y << tmes x else True)))))
(x: t)
: Pure t (requires (tinv true x)) (ensures (fun y -> tinv false y)) (decreases (tmes x)) | [
"recursion"
] | C.Compat.Loops.total_while_gen | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
tmes: (x: t -> Prims.GTot (a x)) ->
tinv: (_: Prims.bool -> _: t -> Prims.GTot Type0) ->
tcontinue: (_: t -> Prims.bool) ->
body: (x: t -> Prims.Pure t) ->
x: t
-> Prims.Pure t | {
"end_col": 8,
"end_line": 469,
"start_col": 1,
"start_line": 465
} |
Prims.Pure | val total_while
(#t: Type)
(tmes: (t -> GTot nat))
(tinv: (bool -> t -> GTot Type0))
(body:
(x: t
-> Pure (bool * t)
(requires (tinv true x))
(ensures
(fun (continue, y) ->
tinv continue y /\ (if continue then tmes y < tmes x else True)))))
(x: t)
: Pure t (requires (tinv true x)) (ensures (fun y -> tinv false y)) (decreases (tmes x)) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let total_while
(#t: Type)
(tmes: (t -> GTot nat))
(tinv: (bool -> t -> GTot Type0))
(body:
(x: t) ->
Pure (bool * t)
(requires (tinv true x))
(ensures (fun (continue, y) ->
tinv continue y /\ (
if continue then tmes y < tmes x else True)
)))
(x: t)
: Pure t
(requires (tinv true x))
(ensures (fun y -> tinv false y))
(decreases (tmes x))
= let (_, res) =
total_while_gen
(fun (_, x) -> tmes x)
(fun b (b_, x) -> b == b_ /\ tinv b x)
(fun (x, _) -> x)
(fun (_, x) -> body x)
(true, x)
in
res | val total_while
(#t: Type)
(tmes: (t -> GTot nat))
(tinv: (bool -> t -> GTot Type0))
(body:
(x: t
-> Pure (bool * t)
(requires (tinv true x))
(ensures
(fun (continue, y) ->
tinv continue y /\ (if continue then tmes y < tmes x else True)))))
(x: t)
: Pure t (requires (tinv true x)) (ensures (fun y -> tinv false y)) (decreases (tmes x))
let total_while
(#t: Type)
(tmes: (t -> GTot nat))
(tinv: (bool -> t -> GTot Type0))
(body:
(x: t
-> Pure (bool * t)
(requires (tinv true x))
(ensures
(fun (continue, y) ->
tinv continue y /\ (if continue then tmes y < tmes x else True)))))
(x: t)
: Pure t (requires (tinv true x)) (ensures (fun y -> tinv false y)) (decreases (tmes x)) = | false | null | false | let _, res =
total_while_gen (fun (_, x) -> tmes x)
(fun b (b_, x) -> b == b_ /\ tinv b x)
(fun (x, _) -> x)
(fun (_, x) -> body x)
(true, x)
in
res | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [
""
] | [
"Prims.nat",
"Prims.bool",
"FStar.Pervasives.Native.tuple2",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.l_True",
"Prims.logical",
"C.Compat.Loops.total_while_gen",
"Prims.eq2",
"FStar.Pervasives.Native.Mktuple2"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end
(* To be extracted as:
int i = <start>;
bool b = false;
for (; (!b) && (i != <end>); --i) {
b = <f> i;
}
// i and b must be in scope after the loop
*)
val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_reverse_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start -^ 1ul) in
if f start
then (start', true)
else interruptible_reverse_for start' finish inv f
(* Non-primitive combinators that can be expressed in terms of the above ******)
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in[i]);
*)
inline_for_extraction
val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) ))
inline_for_extraction
let map #a #b output input l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 input /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 input j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = input.(i) in
output.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map f (as_seq h0 input))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let map2 #a #b #c output in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 in1 /\ live h1 in2 /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
output.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* b[i] = <f>(b[i]);
*)
inline_for_extraction
val in_place_map:
#a:Type0 ->
b: buffer a ->
l: UInt32.t{ UInt32.v l = Buffer.length b } ->
f:(a -> Tot a) ->
Stack unit
(requires (fun h -> live h b))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_2 b /\ live h_1 b
/\ (let s1 = as_seq h_1 b in
let s2 = as_seq h_2 b in
s2 == seq_map f s1) ))
inline_for_extraction
let in_place_map #a b l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 b j == get h0 b j)
/\ (forall (j:nat). j < i ==> get h1 b j == f (get h0 b j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = b.(i) in
b.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 b) (seq_map f (as_seq h0 b))
(** Extracts as (destination buffer comes first):
* for (int i = 0; i < <l>; ++i)
* in1[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val in_place_map2:
#a:Type0 -> #b:Type0 ->
in1: buffer a ->
in2: buffer b{disjoint in1 in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length in1 /\ UInt32.v l = Buffer.length in2} ->
f:(a -> b -> Tot a) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2))
(ensures (fun h_1 r h_2 -> modifies_1 in1 h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 in1 in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let in_place_map2 #a #b in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 in1 /\ live h1 in2 /\ modifies_1 in1 h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 in1 j == get h0 in1 j)
/\ (forall (j:nat). j < i ==> get h1 in1 j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
in1.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 in1) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
#reset-options "--initial_fuel 2 --max_fuel 2 --z3rlimit 20"
(* Repeating the same operation a number of times over a buffer ***************)
#reset-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** To be extracted as:
* for (int i = 0; i < n; ++i)
* f(b[i]);
*)
inline_for_extraction
val repeat:
#a:Type0 ->
l: UInt32.t ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
max:UInt32.t ->
fc:(b:buffer a{length b = UInt32.v l} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0)))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_spec (UInt32.v max) f s) ))
inline_for_extraction
let repeat #a l f b max fc =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v max
/\ as_seq h1 b == repeat_spec i f (as_seq h0 b)
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v max ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
fc b;
lemma_repeat (UInt32.v i + 1) f (as_seq h0 b)
in
lemma_repeat_0 0 f (as_seq h0 b);
for 0ul max inv f'
(** To be extracted as:
* for (int i = min; i < max; ++i)
* f(b[i], i);
*)
inline_for_extraction
val repeat_range:
#a:Type0 ->
l: UInt32.t ->
min:UInt32.t ->
max:UInt32.t{UInt32.v min <= UInt32.v max} ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> i:nat{i < UInt32.v max} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
fc:(b:buffer a{length b = UInt32.v l} -> i:UInt32.t{UInt32.v i < UInt32.v max} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0 (UInt32.v i))))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_range_spec (UInt32.v min) (UInt32.v max) f s) ))
inline_for_extraction
let repeat_range #a l min max f b fc =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v max /\ UInt32.v min <= i
/\ as_seq h1 b == repeat_range_spec (UInt32.v min) i f (as_seq h0 b)
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v max ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
fc b i;
lemma_repeat_range_spec (UInt32.v min) (UInt32.v i + 1) f (as_seq h0 b)
in
lemma_repeat_range_0 (UInt32.v min) f (as_seq h0 b);
for min max inv f'
let rec total_while_gen
(#t: Type)
(#a:t -> Type)
(tmes: (x:t -> GTot (a x)))
(tinv: (bool -> t -> GTot Type0))
(tcontinue: (t -> Tot bool))
(body:
(x: t) ->
Pure t
(requires (tinv true x))
(ensures (fun y ->
tinv (tcontinue y) y /\ (
if tcontinue y then tmes y << tmes x else True)
)))
(x: t)
: Pure t
(requires (tinv true x))
(ensures (fun y -> tinv false y))
(decreases (tmes x))
= let y = body x in
let continue = tcontinue y in
if continue
then total_while_gen tmes tinv tcontinue body y
else y
inline_for_extraction
let total_while
(#t: Type)
(tmes: (t -> GTot nat))
(tinv: (bool -> t -> GTot Type0))
(body:
(x: t) ->
Pure (bool * t)
(requires (tinv true x))
(ensures (fun (continue, y) ->
tinv continue y /\ (
if continue then tmes y < tmes x else True)
)))
(x: t)
: Pure t
(requires (tinv true x))
(ensures (fun y -> tinv false y)) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val total_while
(#t: Type)
(tmes: (t -> GTot nat))
(tinv: (bool -> t -> GTot Type0))
(body:
(x: t
-> Pure (bool * t)
(requires (tinv true x))
(ensures
(fun (continue, y) ->
tinv continue y /\ (if continue then tmes y < tmes x else True)))))
(x: t)
: Pure t (requires (tinv true x)) (ensures (fun y -> tinv false y)) (decreases (tmes x)) | [] | C.Compat.Loops.total_while | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
tmes: (_: t -> Prims.GTot Prims.nat) ->
tinv: (_: Prims.bool -> _: t -> Prims.GTot Type0) ->
body: (x: t -> Prims.Pure (Prims.bool * t)) ->
x: t
-> Prims.Pure t | {
"end_col": 5,
"end_line": 497,
"start_col": 1,
"start_line": 489
} |
FStar.HyperStack.ST.Stack | val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish))) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_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 reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end | val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f = | true | null | false | if start = finish
then ()
else
(f start;
reverse_for (let open UInt32 in start -^ 1ul) finish inv f) | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_GreaterThan",
"Prims.unit",
"Prims.op_Subtraction",
"Prims.op_Equality",
"Prims.bool",
"C.Compat.Loops.reverse_for",
"FStar.UInt32.op_Subtraction_Hat",
"FStar.UInt32.__uint_to_t"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish))) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish))) | [
"recursion"
] | C.Compat.Loops.reverse_for | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
start: FStar.UInt32.t ->
finish: FStar.UInt32.t{FStar.UInt32.v finish <= FStar.UInt32.v start} ->
inv: (_: FStar.Monotonic.HyperStack.mem -> _: Prims.nat -> Type0) ->
f:
(
i:
FStar.UInt32.t
{ FStar.UInt32.v start >= FStar.UInt32.v i /\
FStar.UInt32.v i > FStar.UInt32.v finish }
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 5,
"end_line": 98,
"start_col": 2,
"start_line": 93
} |
FStar.HyperStack.ST.Stack | val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish))) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_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 for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end | val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f = | true | null | false | if start = finish
then ()
else
(f start;
for (let open UInt32 in start +^ 1ul) finish inv f) | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.unit",
"Prims.op_Addition",
"Prims.op_Equality",
"Prims.bool",
"C.Compat.Loops.for",
"FStar.UInt32.op_Plus_Hat",
"FStar.UInt32.__uint_to_t"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish))) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish))) | [
"recursion"
] | C.Compat.Loops.for | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
start: FStar.UInt32.t ->
finish: FStar.UInt32.t{FStar.UInt32.v finish >= FStar.UInt32.v start} ->
inv: (_: FStar.Monotonic.HyperStack.mem -> _: Prims.nat -> Type0) ->
f:
(
i:
FStar.UInt32.t
{ FStar.UInt32.v start <= FStar.UInt32.v i /\
FStar.UInt32.v i < FStar.UInt32.v finish }
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 5,
"end_line": 57,
"start_col": 2,
"start_line": 52
} |
FStar.HyperStack.ST.Stack | val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish))) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_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 for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end | val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f = | true | null | false | if start = finish
then ()
else
(f start;
for64 (let open UInt64 in start +^ 1uL) finish inv f) | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.UInt64.t",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt64.v",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.unit",
"Prims.op_Addition",
"Prims.op_Equality",
"Prims.bool",
"C.Compat.Loops.for64",
"FStar.UInt64.op_Plus_Hat",
"FStar.UInt64.__uint_to_t"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish))) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish))) | [
"recursion"
] | C.Compat.Loops.for64 | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
start: FStar.UInt64.t ->
finish: FStar.UInt64.t{FStar.UInt64.v finish >= FStar.UInt64.v start} ->
inv: (_: FStar.Monotonic.HyperStack.mem -> _: Prims.nat -> Type0) ->
f:
(
i:
FStar.UInt64.t
{ FStar.UInt64.v start <= FStar.UInt64.v i /\
FStar.UInt64.v i < FStar.UInt64.v finish }
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 5,
"end_line": 75,
"start_col": 2,
"start_line": 70
} |
FStar.HyperStack.ST.Stack | val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b))) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_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 interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f | val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f = | true | null | false | if start = finish
then (finish, false)
else
let start' = let open UInt32 in start +^ 1ul in
if f start then (start', true) else interruptible_for start' finish inv f | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Prims.bool",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"Prims.op_Equality",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"C.Compat.Loops.interruptible_for",
"FStar.UInt32.op_Plus_Hat",
"FStar.UInt32.__uint_to_t"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b))) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b))) | [
"recursion"
] | C.Compat.Loops.interruptible_for | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
start: FStar.UInt32.t ->
finish: FStar.UInt32.t{FStar.UInt32.v finish >= FStar.UInt32.v start} ->
inv: (_: FStar.Monotonic.HyperStack.mem -> _: Prims.nat -> _: Prims.bool -> Prims.GTot Type0) ->
f:
(
i:
FStar.UInt32.t
{ FStar.UInt32.v start <= FStar.UInt32.v i /\
FStar.UInt32.v i < FStar.UInt32.v finish }
-> FStar.HyperStack.ST.Stack Prims.bool)
-> FStar.HyperStack.ST.Stack (FStar.UInt32.t * Prims.bool) | {
"end_col": 46,
"end_line": 125,
"start_col": 2,
"start_line": 119
} |
FStar.HyperStack.ST.Stack | val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b))) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_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 interruptible_reverse_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start -^ 1ul) in
if f start
then (start', true)
else interruptible_reverse_for start' finish inv f | val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_reverse_for start finish inv f = | true | null | false | if start = finish
then (finish, false)
else
let start' = let open UInt32 in start -^ 1ul in
if f start then (start', true) else interruptible_reverse_for start' finish inv f | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.UInt32.v",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Prims.bool",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Prims.op_GreaterThan",
"Prims.op_Subtraction",
"Prims.op_Equality",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"C.Compat.Loops.interruptible_reverse_for",
"FStar.UInt32.op_Subtraction_Hat",
"FStar.UInt32.__uint_to_t"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end
(* To be extracted as:
int i = <start>;
bool b = false;
for (; (!b) && (i != <end>); --i) {
b = <f> i;
}
// i and b must be in scope after the loop
*)
val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b))) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b))) | [
"recursion"
] | C.Compat.Loops.interruptible_reverse_for | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
start: FStar.UInt32.t ->
finish: FStar.UInt32.t{FStar.UInt32.v finish <= FStar.UInt32.v start} ->
inv: (_: FStar.Monotonic.HyperStack.mem -> _: Prims.nat -> _: Prims.bool -> Prims.GTot Type0) ->
f:
(
i:
FStar.UInt32.t
{ FStar.UInt32.v start >= FStar.UInt32.v i /\
FStar.UInt32.v i > FStar.UInt32.v finish }
-> FStar.HyperStack.ST.Stack Prims.bool)
-> FStar.HyperStack.ST.Stack (FStar.UInt32.t * Prims.bool) | {
"end_col": 54,
"end_line": 197,
"start_col": 2,
"start_line": 191
} |
FStar.HyperStack.ST.Stack | val in_place_map:
#a:Type0 ->
b: buffer a ->
l: UInt32.t{ UInt32.v l = Buffer.length b } ->
f:(a -> Tot a) ->
Stack unit
(requires (fun h -> live h b))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_2 b /\ live h_1 b
/\ (let s1 = as_seq h_1 b in
let s2 = as_seq h_2 b in
s2 == seq_map f s1) )) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let in_place_map #a b l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 b j == get h0 b j)
/\ (forall (j:nat). j < i ==> get h1 b j == f (get h0 b j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = b.(i) in
b.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 b) (seq_map f (as_seq h0 b)) | val in_place_map:
#a:Type0 ->
b: buffer a ->
l: UInt32.t{ UInt32.v l = Buffer.length b } ->
f:(a -> Tot a) ->
Stack unit
(requires (fun h -> live h b))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_2 b /\ live h_1 b
/\ (let s1 = as_seq h_1 b in
let s2 = as_seq h_2 b in
s2 == seq_map f s1) ))
let in_place_map #a b l f = | true | null | false | let h0 = HST.get () in
let inv (h1: HS.mem) (i: nat) : Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v l /\
(forall (j: nat). (j >= i /\ j < UInt32.v l) ==> get h1 b j == get h0 b j) /\
(forall (j: nat). j < i ==> get h1 b j == f (get h0 b j))
in
let f' (i: UInt32.t{let open UInt32 in 0 <= v i /\ v i < v l})
: Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> let open UInt32 in inv h_2 (v i + 1))) =
let xi = b.(i) in
b.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get () in
Seq.lemma_eq_intro (as_seq h1 b) (seq_map f (as_seq h0 b)) | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.Buffer.buffer",
"FStar.UInt32.t",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"FStar.Buffer.length",
"FStar.Seq.Base.lemma_eq_intro",
"FStar.Buffer.as_seq",
"Spec.Loops.seq_map",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"C.Compat.Loops.for",
"FStar.UInt32.__uint_to_t",
"Prims.l_and",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"FStar.Buffer.op_Array_Assignment",
"FStar.Buffer.op_Array_Access",
"Prims.nat",
"FStar.Buffer.live",
"FStar.Buffer.modifies_1",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.eq2",
"FStar.Buffer.get"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end
(* To be extracted as:
int i = <start>;
bool b = false;
for (; (!b) && (i != <end>); --i) {
b = <f> i;
}
// i and b must be in scope after the loop
*)
val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_reverse_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start -^ 1ul) in
if f start
then (start', true)
else interruptible_reverse_for start' finish inv f
(* Non-primitive combinators that can be expressed in terms of the above ******)
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in[i]);
*)
inline_for_extraction
val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) ))
inline_for_extraction
let map #a #b output input l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 input /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 input j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = input.(i) in
output.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map f (as_seq h0 input))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let map2 #a #b #c output in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 in1 /\ live h1 in2 /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
output.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* b[i] = <f>(b[i]);
*)
inline_for_extraction
val in_place_map:
#a:Type0 ->
b: buffer a ->
l: UInt32.t{ UInt32.v l = Buffer.length b } ->
f:(a -> Tot a) ->
Stack unit
(requires (fun h -> live h b))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_2 b /\ live h_1 b
/\ (let s1 = as_seq h_1 b in
let s2 = as_seq h_2 b in
s2 == seq_map f s1) )) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val in_place_map:
#a:Type0 ->
b: buffer a ->
l: UInt32.t{ UInt32.v l = Buffer.length b } ->
f:(a -> Tot a) ->
Stack unit
(requires (fun h -> live h b))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_2 b /\ live h_1 b
/\ (let s1 = as_seq h_1 b in
let s2 = as_seq h_2 b in
s2 == seq_map f s1) )) | [] | C.Compat.Loops.in_place_map | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
b: FStar.Buffer.buffer a ->
l: FStar.UInt32.t{FStar.UInt32.v l = FStar.Buffer.length b} ->
f: (_: a -> a)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 60,
"end_line": 314,
"start_col": 27,
"start_line": 298
} |
FStar.HyperStack.ST.Stack | val repeat:
#a:Type0 ->
l: UInt32.t ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
max:UInt32.t ->
fc:(b:buffer a{length b = UInt32.v l} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0)))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_spec (UInt32.v max) f s) )) | [
{
"abbrev": false,
"full_module": "Spec.Loops",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.UInt64",
"short_module": "UInt64"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "UInt32"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "HST"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": false,
"full_module": "FStar.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "C.Compat",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let repeat #a l f b max fc =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v max
/\ as_seq h1 b == repeat_spec i f (as_seq h0 b)
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v max ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
fc b;
lemma_repeat (UInt32.v i + 1) f (as_seq h0 b)
in
lemma_repeat_0 0 f (as_seq h0 b);
for 0ul max inv f' | val repeat:
#a:Type0 ->
l: UInt32.t ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
max:UInt32.t ->
fc:(b:buffer a{length b = UInt32.v l} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0)))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_spec (UInt32.v max) f s) ))
let repeat #a l f b max fc = | true | null | false | let h0 = HST.get () in
let inv (h1: HS.mem) (i: nat) : Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v max /\
as_seq h1 b == repeat_spec i f (as_seq h0 b)
in
let f' (i: UInt32.t{let open UInt32 in 0 <= v i /\ v i < v max})
: Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> let open UInt32 in inv h_2 (v i + 1))) =
fc b;
lemma_repeat (UInt32.v i + 1) f (as_seq h0 b)
in
lemma_repeat_0 0 f (as_seq h0 b);
for 0ul max inv f' | {
"checked_file": "C.Compat.Loops.fst.checked",
"dependencies": [
"Spec.Loops.fst.checked",
"prims.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.Buffer.fst.checked"
],
"interface_file": false,
"source_file": "C.Compat.Loops.fst"
} | [] | [
"FStar.UInt32.t",
"FStar.Seq.Base.seq",
"Prims.b2t",
"Prims.op_Equality",
"Prims.int",
"Prims.l_or",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt.size",
"FStar.UInt32.n",
"FStar.Seq.Base.length",
"FStar.UInt32.v",
"Prims.nat",
"FStar.Buffer.buffer",
"FStar.Buffer.length",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.Buffer.live",
"Prims.l_and",
"FStar.Buffer.modifies_1",
"Prims.eq2",
"FStar.Buffer.as_seq",
"C.Compat.Loops.for",
"FStar.UInt32.__uint_to_t",
"Spec.Loops.lemma_repeat_0",
"Prims.op_LessThanOrEqual",
"Prims.op_LessThan",
"Prims.op_Addition",
"Spec.Loops.lemma_repeat",
"Spec.Loops.repeat_spec",
"FStar.HyperStack.ST.get"
] | [] | (* This module exposes a series of combinators; they are modeled using
* higher-order functions and specifications, and extracted, using a
* meta-theoretic argument, to actual C loops. *)
module C.Compat.Loops
open FStar.HyperStack.ST
open FStar.Buffer
module HS = FStar.HyperStack
module HST = FStar.HyperStack.ST
module UInt32 = FStar.UInt32
module UInt64 = FStar.UInt64
include Spec.Loops
#set-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** The functions in this module use the following convention:
* - the first arguments are buffers;
* - the destination buffer comes first, followed by the input buffer (as in
* C's memcpy)
* - each buffer is followed by its length; if several buffers share the same
* length, there is a single length argument after the buffers
* - the function-specific arguments come next (e.g. the number of times one
* may want to call the function in [repeat])
* - the second to last argument is the loop invariant (which may have
* dependencies on all the parameters before)
* - the last argument is the loop body (that will depend on the invariant, and
* possibly all the other parameters before. *)
(* Generic-purpose for-loop combinators ***************************************)
(* These combinators enjoy first-class support in KaRaMeL. (See [combinators] in
* src/Simplify.ml *)
(* Currently extracting as:
for (int i = <start>; i != <finish>; ++i)
<f> i;
*)
val for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec for start finish inv f =
if start = finish then
()
else begin
f start;
for (UInt32.(start +^ 1ul)) finish inv f
end
val for64:
start:UInt64.t ->
finish:UInt64.t{UInt64.v finish >= UInt64.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt64.t{UInt64.(v start <= v i /\ v i < v finish)} -> Stack unit
(requires (fun h -> inv h (UInt64.v i)))
(ensures (fun h_1 _ h_2 -> UInt64.(inv h_1 (v i) /\ inv h_2 (v i + 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt64.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt64.v finish)))
let rec for64 start finish inv f =
if start = finish then
()
else begin
f start;
for64 (UInt64.(start +^ 1UL)) finish inv f
end
(* To be extracted as:
for (int i = <start>; i != <finish>; --i)
<f> i;
*)
val reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_1 (v i) /\ inv h_2 (v i - 1)))) ) ->
Stack unit
(requires (fun h -> inv h (UInt32.v start)))
(ensures (fun _ _ h_2 -> inv h_2 (UInt32.v finish)))
let rec reverse_for start finish inv f =
if start = finish then
()
else begin
f start;
reverse_for (UInt32.(start -^ 1ul)) finish inv f
end
(* To be extracted as:
bool b = false;
int i = <start>;
for (; (!b) && (i != <end>); ++i) {
b = <f> i;
}
(i, b)
*)
val interruptible_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish >= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start <= v i /\ v i < v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i + 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start +^ 1ul) in
if f start
then (start', true)
else interruptible_for start' finish inv f
(* To be extracted as:
while (true) {
bool b = <f> i;
if (b) {
break;
}
}
*)
val do_while:
inv:(HS.mem -> bool -> GTot Type0) ->
f:(unit -> Stack bool
(requires (fun h -> inv h false))
(ensures (fun h_1 b h_2 -> inv h_1 false /\ inv h_2 b)) ) ->
Stack unit
(requires (fun h -> inv h false))
(ensures (fun _ _ h_2 -> inv h_2 true))
let rec do_while inv f =
if not (f ()) then
do_while inv f
(* Extracted as:
while (test ()) {
body ();
}
*)
val while:
#test_pre: (HS.mem -> GTot Type0) ->
#test_post: (bool -> HS.mem -> GTot Type0) ->
$test: (unit -> Stack bool
(requires (fun h -> test_pre h))
(ensures (fun h0 x h1 -> test_post x h1))) ->
body: (unit -> Stack unit
(requires (fun h -> test_post true h))
(ensures (fun h0 _ h1 -> test_pre h1))) ->
Stack unit
(requires (fun h -> test_pre h))
(ensures (fun h0 _ h1 -> test_post false h1))
let rec while #test_pre #test_post test body =
if test () then begin
body ();
while #test_pre #test_post test body
end
(* To be extracted as:
int i = <start>;
bool b = false;
for (; (!b) && (i != <end>); --i) {
b = <f> i;
}
// i and b must be in scope after the loop
*)
val interruptible_reverse_for:
start:UInt32.t ->
finish:UInt32.t{UInt32.v finish <= UInt32.v start} ->
inv:(HS.mem -> nat -> bool -> GTot Type0) ->
f:(i:UInt32.t{UInt32.(v start >= v i /\ v i > v finish)} -> Stack bool
(requires (fun h -> inv h (UInt32.v i) false))
(ensures (fun h_1 b h_2 -> inv h_1 (UInt32.v i) false /\ inv h_2 UInt32.(v i - 1) b)) ) ->
Stack (UInt32.t * bool)
(requires (fun h -> inv h (UInt32.v start) false))
(ensures (fun _ res h_2 -> let (i, b) = res in ((if b then True else i == finish) /\ inv h_2 (UInt32.v i) b)))
let rec interruptible_reverse_for start finish inv f =
if start = finish then
(finish, false)
else
let start' = UInt32.(start -^ 1ul) in
if f start
then (start', true)
else interruptible_reverse_for start' finish inv f
(* Non-primitive combinators that can be expressed in terms of the above ******)
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in[i]);
*)
inline_for_extraction
val map:
#a:Type0 -> #b:Type0 ->
output: buffer b ->
input: buffer a{disjoint input output} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length input } ->
f:(a -> Tot b) ->
Stack unit
(requires (fun h -> live h input /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 input /\ live h_1 input /\ live h_2 output
/\ live h_2 output
/\ (let s1 = as_seq h_1 input in
let s2 = as_seq h_2 output in
s2 == seq_map f s1) ))
inline_for_extraction
let map #a #b output input l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 input /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 input j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = input.(i) in
output.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map f (as_seq h0 input))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* out[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val map2:
#a:Type0 -> #b:Type0 -> #c:Type0 ->
output: buffer c ->
in1: buffer a{disjoint output in1} -> in2: buffer b{disjoint output in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length output /\ UInt32.v l = Buffer.length in1
/\ UInt32.v l = Buffer.length in2 } ->
f:(a -> b -> Tot c) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2 /\ live h output ))
(ensures (fun h_1 r h_2 -> modifies_1 output h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2 /\ live h_2 output
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 output in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let map2 #a #b #c output in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 output /\ live h1 in1 /\ live h1 in2 /\ modifies_1 output h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 output j == get h0 output j)
/\ (forall (j:nat). j < i ==> get h1 output j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
output.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 output) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
(** Extracts as:
* for (int i = 0; i < <l>; ++i)
* b[i] = <f>(b[i]);
*)
inline_for_extraction
val in_place_map:
#a:Type0 ->
b: buffer a ->
l: UInt32.t{ UInt32.v l = Buffer.length b } ->
f:(a -> Tot a) ->
Stack unit
(requires (fun h -> live h b))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_2 b /\ live h_1 b
/\ (let s1 = as_seq h_1 b in
let s2 = as_seq h_2 b in
s2 == seq_map f s1) ))
inline_for_extraction
let in_place_map #a b l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 b /\ modifies_1 b h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 b j == get h0 b j)
/\ (forall (j:nat). j < i ==> get h1 b j == f (get h0 b j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = b.(i) in
b.(i) <- f xi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 b) (seq_map f (as_seq h0 b))
(** Extracts as (destination buffer comes first):
* for (int i = 0; i < <l>; ++i)
* in1[i] = <f>(in1[i], in2[i]);
*)
inline_for_extraction
val in_place_map2:
#a:Type0 -> #b:Type0 ->
in1: buffer a ->
in2: buffer b{disjoint in1 in2} ->
l: UInt32.t{ UInt32.v l = Buffer.length in1 /\ UInt32.v l = Buffer.length in2} ->
f:(a -> b -> Tot a) ->
Stack unit
(requires (fun h -> live h in1 /\ live h in2))
(ensures (fun h_1 r h_2 -> modifies_1 in1 h_1 h_2 /\ live h_2 in1 /\ live h_2 in2
/\ live h_1 in1 /\ live h_1 in2
/\ (let s1 = as_seq h_1 in1 in
let s2 = as_seq h_1 in2 in
let s = as_seq h_2 in1 in
s == seq_map2 f s1 s2) ))
inline_for_extraction
let in_place_map2 #a #b in1 in2 l f =
let h0 = HST.get() in
let inv (h1: HS.mem) (i: nat): Type0 =
live h1 in1 /\ live h1 in2 /\ modifies_1 in1 h0 h1 /\ i <= UInt32.v l
/\ (forall (j:nat). (j >= i /\ j < UInt32.v l) ==> get h1 in1 j == get h0 in1 j)
/\ (forall (j:nat). j < i ==> get h1 in1 j == f (get h0 in1 j) (get h0 in2 j))
in
let f' (i:UInt32.t{ UInt32.( 0 <= v i /\ v i < v l ) }): Stack unit
(requires (fun h -> inv h (UInt32.v i)))
(ensures (fun h_1 _ h_2 -> UInt32.(inv h_2 (v i + 1))))
=
let xi = in1.(i) in
let yi = in2.(i) in
in1.(i) <- f xi yi
in
for 0ul l inv f';
let h1 = HST.get() in
Seq.lemma_eq_intro (as_seq h1 in1) (seq_map2 f (as_seq h0 in1) (as_seq h0 in2))
#reset-options "--initial_fuel 2 --max_fuel 2 --z3rlimit 20"
(* Repeating the same operation a number of times over a buffer ***************)
#reset-options "--initial_fuel 0 --max_fuel 0 --z3rlimit 20"
(** To be extracted as:
* for (int i = 0; i < n; ++i)
* f(b[i]);
*)
inline_for_extraction
val repeat:
#a:Type0 ->
l: UInt32.t ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
max:UInt32.t ->
fc:(b:buffer a{length b = UInt32.v l} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0)))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_spec (UInt32.v max) f s) )) | false | false | C.Compat.Loops.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 1,
"max_fuel": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val repeat:
#a:Type0 ->
l: UInt32.t ->
f:(s:Seq.seq a{Seq.length s = UInt32.v l} -> Tot (s':Seq.seq a{Seq.length s' = Seq.length s})) ->
b: buffer a{Buffer.length b = UInt32.v l} ->
max:UInt32.t ->
fc:(b:buffer a{length b = UInt32.v l} -> Stack unit
(requires (fun h -> live h b))
(ensures (fun h0 _ h1 -> live h0 b /\ live h1 b /\ modifies_1 b h0 h1
/\ (let b0 = as_seq h0 b in
let b1 = as_seq h1 b in
b1 == f b0)))) ->
Stack unit
(requires (fun h -> live h b ))
(ensures (fun h_1 r h_2 -> modifies_1 b h_1 h_2 /\ live h_1 b /\ live h_2 b
/\ (let s = as_seq h_1 b in
let s' = as_seq h_2 b in
s' == repeat_spec (UInt32.v max) f s) )) | [] | C.Compat.Loops.repeat | {
"file_name": "krmllib/compat/C.Compat.Loops.fst",
"git_rev": "a7be2a7c43eca637ceb57fe8f3ffd16fc6627ebd",
"git_url": "https://github.com/FStarLang/karamel.git",
"project_name": "karamel"
} |
l: FStar.UInt32.t ->
f:
(s: FStar.Seq.Base.seq a {FStar.Seq.Base.length s = FStar.UInt32.v l}
-> s': FStar.Seq.Base.seq a {FStar.Seq.Base.length s' = FStar.Seq.Base.length s}) ->
b: FStar.Buffer.buffer a {FStar.Buffer.length b = FStar.UInt32.v l} ->
max: FStar.UInt32.t ->
fc:
(b: FStar.Buffer.buffer a {FStar.Buffer.length b = FStar.UInt32.v l}
-> FStar.HyperStack.ST.Stack Prims.unit)
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 20,
"end_line": 402,
"start_col": 28,
"start_line": 388
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.