effect
stringclasses 48
values | original_source_type
stringlengths 0
23k
| opens_and_abbrevs
listlengths 2
92
| isa_cross_project_example
bool 1
class | source_definition
stringlengths 9
57.9k
| partial_definition
stringlengths 7
23.3k
| is_div
bool 2
classes | is_type
null | is_proof
bool 2
classes | completed_definiton
stringlengths 1
250k
| dependencies
dict | effect_flags
sequencelengths 0
2
| ideal_premises
sequencelengths 0
236
| mutual_with
sequencelengths 0
11
| file_context
stringlengths 0
407k
| interleaved
bool 1
class | is_simply_typed
bool 2
classes | file_name
stringlengths 5
48
| vconfig
dict | is_simple_lemma
null | source_type
stringlengths 10
23k
| proof_features
sequencelengths 0
1
| name
stringlengths 8
95
| source
dict | verbose_type
stringlengths 1
7.42k
| source_range
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FStar.HyperStack.ST.Stack | val frodo_sample_matrix1:
a:FP.frodo_alg
-> frodo_sample:frodo_sample_st a
-> n1:size_t
-> n2:size_t{0 < 2 * v n1 * v n2 /\ 2 * v n1 * v n2 <= max_size_t}
-> r:lbuffer uint8 (size 2 *! n1 *! n2)
-> i:size_t{v i < v n1}
-> res:matrix_t n1 n2
-> Stack unit
(requires fun h ->
live h r /\ live h res /\ disjoint r res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_sample_matrix1 a (v n1) (v n2) (as_seq h0 r) (v i) (as_matrix h0 res)) | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Sample",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_sample_matrix1 a frodo_sample n1 n2 r i res =
[@ inline_let]
let spec h0 = S.frodo_sample_matrix0 a (v n1) (v n2) (as_seq h0 r) (v i) in
let h0 = ST.get () in
loop1 h0 n2 res spec
(fun j ->
Loops.unfold_repeati (v n2) (spec h0) (as_seq h0 res) (v j);
Lemmas.lemma_matrix_index_repeati1 (v n1) (v n2) (v i) (v j);
let resij = sub r (size 2 *! (n2 *! i +! j)) (size 2) in
mset res i j (frodo_sample (uint_from_bytes_le #U16 resij))
) | val frodo_sample_matrix1:
a:FP.frodo_alg
-> frodo_sample:frodo_sample_st a
-> n1:size_t
-> n2:size_t{0 < 2 * v n1 * v n2 /\ 2 * v n1 * v n2 <= max_size_t}
-> r:lbuffer uint8 (size 2 *! n1 *! n2)
-> i:size_t{v i < v n1}
-> res:matrix_t n1 n2
-> Stack unit
(requires fun h ->
live h r /\ live h res /\ disjoint r res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_sample_matrix1 a (v n1) (v n2) (as_seq h0 r) (v i) (as_matrix h0 res))
let frodo_sample_matrix1 a frodo_sample n1 n2 r i res = | true | null | false | [@@ inline_let ]let spec h0 = S.frodo_sample_matrix0 a (v n1) (v n2) (as_seq h0 r) (v i) in
let h0 = ST.get () in
loop1 h0
n2
res
spec
(fun j ->
Loops.unfold_repeati (v n2) (spec h0) (as_seq h0 res) (v j);
Lemmas.lemma_matrix_index_repeati1 (v n1) (v n2) (v i) (v j);
let resij = sub r (size 2 *! (n2 *! i +! j)) (size 2) in
mset res i j (frodo_sample (uint_from_bytes_le #U16 resij))) | {
"checked_file": "Hacl.Impl.Frodo.Sample.fst.checked",
"dependencies": [
"Spec.Frodo.Sample.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Sample.fst"
} | [] | [
"Spec.Frodo.Params.frodo_alg",
"Hacl.Impl.Frodo.Sample.frodo_sample_st",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size",
"Hacl.Impl.Matrix.matrix_t",
"Lib.Buffer.loop1",
"Hacl.Impl.Matrix.elem",
"Hacl.Impl.Matrix.mset",
"Prims.unit",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Lib.IntTypes.uint16",
"Lib.ByteBuffer.uint_from_bytes_le",
"Lib.IntTypes.uint_t",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Lib.IntTypes.U8",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub",
"Lib.IntTypes.op_Plus_Bang",
"Spec.Frodo.Lemmas.lemma_matrix_index_repeati1",
"Lib.LoopCombinators.unfold_repeati",
"Lib.Sequence.lseq",
"Prims.op_Multiply",
"Lib.Buffer.as_seq",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Prims.nat",
"Prims.op_Subtraction",
"Prims.pow2",
"Spec.Frodo.Sample.frodo_sample_matrix0"
] | [] | module Hacl.Impl.Frodo.Sample
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module Lemmas = Spec.Frodo.Lemmas
module S = Spec.Frodo.Sample
module FP = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_sample_f:
a:FP.frodo_alg
-> t:uint16{uint_v t < pow2 15}
-> i:size_t{v i < v (cdf_table_len a)}
-> Stack uint16
(requires fun h -> True)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
v r == S.frodo_sample_f a t (v i))
let frodo_sample_f a t i =
recall_contents (cdf_table a) (FP.cdf_table a);
let ti = index (cdf_table a) i in
FP.lemma_cdf_list a (v i);
Lemmas.lemma_frodo_sample t ti;
to_u16 (to_u32 (ti -. t)) >>. 15ul
inline_for_extraction noextract
val frodo_sample_res:
a:FP.frodo_alg
-> sign:uint16{v sign <= 1}
-> sample:uint16{v sample < v (cdf_table_len a)}
-> res:uint16{res == S.frodo_sample_res a sign (v sample)}
let frodo_sample_res a sign sample =
Lemmas.lemma_frodo_sample2 sign sample;
((lognot sign +. u16 1) ^. sample) +. sign
inline_for_extraction noextract
let frodo_sample_st (a:FP.frodo_alg) =
r:uint16
-> Stack uint16
(requires fun h -> True)
(ensures fun h0 res h1 -> modifies0 h0 h1 /\
res == S.frodo_sample a r)
#push-options "--fuel 1"
inline_for_extraction noextract
val frodo_sample: a:FP.frodo_alg -> frodo_sample_st a
let frodo_sample a r =
push_frame();
let prnd = r >>. 1ul in
let sign = r &. u16 1 in
mod_mask_lemma r 1ul;
assert (v #U16 #SEC (mod_mask 1ul) == 1);
assert (v sign == 0 \/ v sign == 1);
let sample :lbuffer uint16 1ul = create (size 1) (u16 0) in
let h = ST.get () in
assert (LSeq.index #_ #1 (as_seq h sample) 0 == u16 0);
assert (bget h sample 0 == u16 0);
let bound = cdf_table_len a -! 1ul in
let h0 = ST.get () in
Lib.Loops.for 0ul bound
(fun h i ->
modifies1 sample h0 h /\
v (bget h sample 0) == S.frodo_sample_fc a prnd i)
(fun i ->
let sample0 = sample.(0ul) in
let samplei = frodo_sample_f a prnd i in
sample.(0ul) <- samplei +. sample0
);
let sample0 = sample.(0ul) in
assert (v sample0 == S.frodo_sample_fc a prnd (v bound));
let res = frodo_sample_res a sign sample0 in
pop_frame();
res
#pop-options
inline_for_extraction noextract
val frodo_sample_matrix1:
a:FP.frodo_alg
-> frodo_sample:frodo_sample_st a
-> n1:size_t
-> n2:size_t{0 < 2 * v n1 * v n2 /\ 2 * v n1 * v n2 <= max_size_t}
-> r:lbuffer uint8 (size 2 *! n1 *! n2)
-> i:size_t{v i < v n1}
-> res:matrix_t n1 n2
-> Stack unit
(requires fun h ->
live h r /\ live h res /\ disjoint r res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_sample_matrix1 a (v n1) (v n2) (as_seq h0 r) (v i) (as_matrix h0 res)) | false | false | Hacl.Impl.Frodo.Sample.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 frodo_sample_matrix1:
a:FP.frodo_alg
-> frodo_sample:frodo_sample_st a
-> n1:size_t
-> n2:size_t{0 < 2 * v n1 * v n2 /\ 2 * v n1 * v n2 <= max_size_t}
-> r:lbuffer uint8 (size 2 *! n1 *! n2)
-> i:size_t{v i < v n1}
-> res:matrix_t n1 n2
-> Stack unit
(requires fun h ->
live h r /\ live h res /\ disjoint r res)
(ensures fun h0 _ h1 -> modifies1 res h0 h1 /\
as_matrix h1 res ==
S.frodo_sample_matrix1 a (v n1) (v n2) (as_seq h0 r) (v i) (as_matrix h0 res)) | [] | Hacl.Impl.Frodo.Sample.frodo_sample_matrix1 | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Sample.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
a: Spec.Frodo.Params.frodo_alg ->
frodo_sample: Hacl.Impl.Frodo.Sample.frodo_sample_st a ->
n1: Lib.IntTypes.size_t ->
n2:
Lib.IntTypes.size_t
{ 0 < (2 * Lib.IntTypes.v n1) * Lib.IntTypes.v n2 /\
(2 * Lib.IntTypes.v n1) * Lib.IntTypes.v n2 <= Lib.IntTypes.max_size_t } ->
r: Lib.Buffer.lbuffer Lib.IntTypes.uint8 (Lib.IntTypes.size 2 *! n1 *! n2) ->
i: Lib.IntTypes.size_t{Lib.IntTypes.v i < Lib.IntTypes.v n1} ->
res: Hacl.Impl.Matrix.matrix_t n1 n2
-> FStar.HyperStack.ST.Stack Prims.unit | {
"end_col": 3,
"end_line": 123,
"start_col": 2,
"start_line": 114
} |
Prims.Tot | val frodo_sample: a:FP.frodo_alg -> frodo_sample_st a | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Sample",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Lemmas",
"short_module": "Lemmas"
},
{
"abbrev": true,
"full_module": "Lib.LoopCombinators",
"short_module": "Loops"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Params",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Matrix",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.ByteBuffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let frodo_sample a r =
push_frame();
let prnd = r >>. 1ul in
let sign = r &. u16 1 in
mod_mask_lemma r 1ul;
assert (v #U16 #SEC (mod_mask 1ul) == 1);
assert (v sign == 0 \/ v sign == 1);
let sample :lbuffer uint16 1ul = create (size 1) (u16 0) in
let h = ST.get () in
assert (LSeq.index #_ #1 (as_seq h sample) 0 == u16 0);
assert (bget h sample 0 == u16 0);
let bound = cdf_table_len a -! 1ul in
let h0 = ST.get () in
Lib.Loops.for 0ul bound
(fun h i ->
modifies1 sample h0 h /\
v (bget h sample 0) == S.frodo_sample_fc a prnd i)
(fun i ->
let sample0 = sample.(0ul) in
let samplei = frodo_sample_f a prnd i in
sample.(0ul) <- samplei +. sample0
);
let sample0 = sample.(0ul) in
assert (v sample0 == S.frodo_sample_fc a prnd (v bound));
let res = frodo_sample_res a sign sample0 in
pop_frame();
res | val frodo_sample: a:FP.frodo_alg -> frodo_sample_st a
let frodo_sample a r = | false | null | false | push_frame ();
let prnd = r >>. 1ul in
let sign = r &. u16 1 in
mod_mask_lemma r 1ul;
assert (v #U16 #SEC (mod_mask 1ul) == 1);
assert (v sign == 0 \/ v sign == 1);
let sample:lbuffer uint16 1ul = create (size 1) (u16 0) in
let h = ST.get () in
assert (LSeq.index #_ #1 (as_seq h sample) 0 == u16 0);
assert (bget h sample 0 == u16 0);
let bound = cdf_table_len a -! 1ul in
let h0 = ST.get () in
Lib.Loops.for 0ul
bound
(fun h i -> modifies1 sample h0 h /\ v (bget h sample 0) == S.frodo_sample_fc a prnd i)
(fun i ->
let sample0 = sample.(0ul) in
let samplei = frodo_sample_f a prnd i in
sample.(0ul) <- samplei +. sample0);
let sample0 = sample.(0ul) in
assert (v sample0 == S.frodo_sample_fc a prnd (v bound));
let res = frodo_sample_res a sign sample0 in
pop_frame ();
res | {
"checked_file": "Hacl.Impl.Frodo.Sample.fst.checked",
"dependencies": [
"Spec.Frodo.Sample.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.Lemmas.fst.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.Loops.fsti.checked",
"Lib.LoopCombinators.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.Sample.fst"
} | [
"total"
] | [
"Spec.Frodo.Params.frodo_alg",
"Lib.IntTypes.uint16",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U16",
"Lib.IntTypes.SEC",
"Prims.eq2",
"Spec.Frodo.Sample.frodo_sample_res",
"Lib.IntTypes.v",
"Hacl.Impl.Frodo.Sample.frodo_sample_res",
"Prims._assert",
"Prims.int",
"Prims.l_or",
"Prims.l_and",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.range",
"Spec.Frodo.Sample.frodo_sample_fc",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.MUT",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.__uint_to_t",
"Lib.Loops.for",
"FStar.Monotonic.HyperStack.mem",
"Prims.nat",
"Lib.Buffer.modifies1",
"Lib.Buffer.bget",
"Lib.IntTypes.size_t",
"Prims.op_LessThan",
"Lib.Buffer.op_Array_Assignment",
"Lib.IntTypes.op_Plus_Dot",
"Hacl.Impl.Frodo.Sample.frodo_sample_f",
"FStar.HyperStack.ST.get",
"Lib.IntTypes.op_Subtraction_Bang",
"Hacl.Impl.Frodo.Params.cdf_table_len",
"Lib.IntTypes.u16",
"Lib.IntTypes.range_t",
"FStar.Seq.Base.index",
"Lib.Sequence.to_seq",
"Lib.Buffer.as_seq",
"Lib.Sequence.index",
"Lib.Buffer.lbuffer_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.size",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.mod_mask",
"Lib.IntTypes.mod_mask_lemma",
"Lib.IntTypes.op_Amp_Dot",
"Lib.IntTypes.op_Greater_Greater_Dot",
"FStar.HyperStack.ST.push_frame"
] | [] | module Hacl.Impl.Frodo.Sample
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Lib.ByteBuffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Loops = Lib.LoopCombinators
module Lemmas = Spec.Frodo.Lemmas
module S = Spec.Frodo.Sample
module FP = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_sample_f:
a:FP.frodo_alg
-> t:uint16{uint_v t < pow2 15}
-> i:size_t{v i < v (cdf_table_len a)}
-> Stack uint16
(requires fun h -> True)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
v r == S.frodo_sample_f a t (v i))
let frodo_sample_f a t i =
recall_contents (cdf_table a) (FP.cdf_table a);
let ti = index (cdf_table a) i in
FP.lemma_cdf_list a (v i);
Lemmas.lemma_frodo_sample t ti;
to_u16 (to_u32 (ti -. t)) >>. 15ul
inline_for_extraction noextract
val frodo_sample_res:
a:FP.frodo_alg
-> sign:uint16{v sign <= 1}
-> sample:uint16{v sample < v (cdf_table_len a)}
-> res:uint16{res == S.frodo_sample_res a sign (v sample)}
let frodo_sample_res a sign sample =
Lemmas.lemma_frodo_sample2 sign sample;
((lognot sign +. u16 1) ^. sample) +. sign
inline_for_extraction noextract
let frodo_sample_st (a:FP.frodo_alg) =
r:uint16
-> Stack uint16
(requires fun h -> True)
(ensures fun h0 res h1 -> modifies0 h0 h1 /\
res == S.frodo_sample a r)
#push-options "--fuel 1"
inline_for_extraction noextract
val frodo_sample: a:FP.frodo_alg -> frodo_sample_st a | false | false | Hacl.Impl.Frodo.Sample.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 1,
"initial_ifuel": 0,
"max_fuel": 1,
"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 frodo_sample: a:FP.frodo_alg -> frodo_sample_st a | [] | Hacl.Impl.Frodo.Sample.frodo_sample | {
"file_name": "code/frodo/Hacl.Impl.Frodo.Sample.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | a: Spec.Frodo.Params.frodo_alg -> Hacl.Impl.Frodo.Sample.frodo_sample_st a | {
"end_col": 5,
"end_line": 93,
"start_col": 2,
"start_line": 67
} |
Prims.Tot | val fits_u32 : prop | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fits_u32 = (reveal bound >= pow2 32) == true | val fits_u32 : prop
let fits_u32 = | false | null | false | (reveal bound >= pow2 32) == true | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [
"total"
] | [
"Prims.eq2",
"Prims.bool",
"Prims.op_GreaterThanOrEqual",
"FStar.Ghost.reveal",
"Prims.nat",
"FStar.SizeT.bound",
"Prims.pow2"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert. | false | true | FStar.SizeT.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 fits_u32 : prop | [] | FStar.SizeT.fits_u32 | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.prop | {
"end_col": 48,
"end_line": 34,
"start_col": 15,
"start_line": 34
} |
Prims.Tot | val fits (x: nat) : Tot prop | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound | val fits (x: nat) : Tot prop
let fits x = | false | null | false | FStar.UInt.fits x U64.n == true /\ x < bound | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [
"total"
] | [
"Prims.nat",
"Prims.l_and",
"Prims.eq2",
"Prims.bool",
"FStar.UInt.fits",
"FStar.UInt64.n",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Ghost.reveal",
"FStar.SizeT.bound",
"Prims.prop"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound } | false | true | FStar.SizeT.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 fits (x: nat) : Tot prop | [] | FStar.SizeT.fits | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.nat -> Prims.prop | {
"end_col": 11,
"end_line": 17,
"start_col": 2,
"start_line": 16
} |
Prims.Tot | val fits_u64 : prop | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let fits_u64 = (reveal bound == pow2 64) | val fits_u64 : prop
let fits_u64 = | false | null | false | (reveal bound == pow2 64) | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [
"total"
] | [
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"Prims.op_GreaterThan",
"FStar.Ghost.reveal",
"Prims.nat",
"FStar.SizeT.bound",
"Prims.pow2"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here | false | true | FStar.SizeT.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 fits_u64 : prop | [] | FStar.SizeT.fits_u64 | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.prop | {
"end_col": 40,
"end_line": 35,
"start_col": 15,
"start_line": 35
} |
Prims.Pure | val v (x: t) : Pure nat
(requires True)
(ensures (fun y -> fits y)) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let v x =
U64.v x | val v (x: t) : Pure nat
(requires True)
(ensures (fun y -> fits y))
let v x = | false | null | false | U64.v x | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"FStar.UInt64.v",
"Prims.nat"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = () | false | false | FStar.SizeT.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val v (x: t) : Pure nat
(requires True)
(ensures (fun y -> fits y)) | [] | FStar.SizeT.v | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.SizeT.t -> Prims.Pure Prims.nat | {
"end_col": 9,
"end_line": 22,
"start_col": 2,
"start_line": 22
} |
Prims.Pure | val gt (x y:t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x > v y))) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gt x y = U64.gt x y | val gt (x y:t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x > v y)))
let gt x y = | false | null | false | U64.gt x y | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"FStar.UInt64.gt",
"Prims.bool"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
let fits_lte x y = ()
#push-options "--z3rlimit 20"
let add x y = U64.add x y
let sub x y = U64.sub x y
let mul x y = U64.mul x y
let div x y =
let res = U64.div x y in
fits_lte (U64.v res) (U64.v x);
FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y);
assert (U64.v x / U64.v y <= U64.v x);
res | false | false | FStar.SizeT.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gt (x y:t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x > v y))) | [] | FStar.SizeT.gt | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure Prims.bool | {
"end_col": 23,
"end_line": 79,
"start_col": 13,
"start_line": 79
} |
Prims.Pure | val uint16_to_sizet (x:U16.t) : Pure t
(requires True)
(ensures fun y -> v y == U16.v x) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint16_to_sizet x = uint_to_t (U16.v x) | val uint16_to_sizet (x:U16.t) : Pure t
(requires True)
(ensures fun y -> v y == U16.v x)
let uint16_to_sizet x = | false | null | false | uint_to_t (U16.v x) | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.UInt16.t",
"FStar.SizeT.uint_to_t",
"FStar.UInt16.v",
"FStar.SizeT.t"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x) | false | false | FStar.SizeT.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_to_sizet (x:U16.t) : Pure t
(requires True)
(ensures fun y -> v y == U16.v x) | [] | FStar.SizeT.uint16_to_sizet | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.UInt16.t -> Prims.Pure FStar.SizeT.t | {
"end_col": 43,
"end_line": 61,
"start_col": 24,
"start_line": 61
} |
Prims.Pure | val gte (x y:t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x >= v y))) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let gte x y = U64.gte x y | val gte (x y:t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x >= v y)))
let gte x y = | false | null | false | U64.gte x y | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"FStar.UInt64.gte",
"Prims.bool"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
let fits_lte x y = ()
#push-options "--z3rlimit 20"
let add x y = U64.add x y
let sub x y = U64.sub x y
let mul x y = U64.mul x y
let div x y =
let res = U64.div x y in
fits_lte (U64.v res) (U64.v x);
FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y);
assert (U64.v x / U64.v y <= U64.v x);
res
let rem x y = U64.rem x y | false | false | FStar.SizeT.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val gte (x y:t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x >= v y))) | [] | FStar.SizeT.gte | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure Prims.bool | {
"end_col": 25,
"end_line": 80,
"start_col": 14,
"start_line": 80
} |
Prims.Pure | val sub (x y: t) : Pure t
(requires (v x >= v y))
(ensures (fun z -> v z == v x - v y)) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sub x y = U64.sub x y | val sub (x y: t) : Pure t
(requires (v x >= v y))
(ensures (fun z -> v z == v x - v y))
let sub x y = | false | null | false | U64.sub x y | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"FStar.UInt64.sub"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
let fits_lte x y = ()
#push-options "--z3rlimit 20" | false | false | FStar.SizeT.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val sub (x y: t) : Pure t
(requires (v x >= v y))
(ensures (fun z -> v z == v x - v y)) | [] | FStar.SizeT.sub | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure FStar.SizeT.t | {
"end_col": 25,
"end_line": 70,
"start_col": 14,
"start_line": 70
} |
Prims.Pure | val of_u64 (x: U64.t) : Pure t
(requires fits_u64)
(ensures (fun y -> v y == U64.v x)) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let of_u64 (x: U64.t)
= uint_to_t (U64.v x) | val of_u64 (x: U64.t) : Pure t
(requires fits_u64)
(ensures (fun y -> v y == U64.v x))
let of_u64 (x: U64.t) = | false | null | false | uint_to_t (U64.v x) | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.UInt64.t",
"FStar.SizeT.uint_to_t",
"FStar.UInt64.v",
"FStar.SizeT.t"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x) | false | false | FStar.SizeT.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 of_u64 (x: U64.t) : Pure t
(requires fits_u64)
(ensures (fun y -> v y == U64.v x)) | [] | FStar.SizeT.of_u64 | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.UInt64.t -> Prims.Pure FStar.SizeT.t | {
"end_col": 23,
"end_line": 59,
"start_col": 4,
"start_line": 59
} |
Prims.Tot | val t : eqtype | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let t = x:U64.t { U64.v x < bound } | val t : eqtype
let t = | false | null | false | x: U64.t{U64.v x < bound} | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [
"total"
] | [
"FStar.UInt64.t",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.UInt64.v",
"FStar.Ghost.reveal",
"Prims.nat",
"FStar.SizeT.bound"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 } | false | true | FStar.SizeT.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val t : eqtype | [] | FStar.SizeT.t | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | Prims.eqtype | {
"end_col": 35,
"end_line": 13,
"start_col": 8,
"start_line": 13
} |
Prims.Pure | val uint_to_t (x: nat) : Pure t
(requires (fits x))
(ensures (fun y -> v y == x)) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint_to_t x =
U64.uint_to_t x | val uint_to_t (x: nat) : Pure t
(requires (fits x))
(ensures (fun y -> v y == x))
let uint_to_t x = | false | null | false | U64.uint_to_t x | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"Prims.nat",
"FStar.UInt64.uint_to_t",
"FStar.SizeT.t"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x | false | false | FStar.SizeT.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 uint_to_t (x: nat) : Pure t
(requires (fits x))
(ensures (fun y -> v y == x)) | [] | FStar.SizeT.uint_to_t | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: Prims.nat -> Prims.Pure FStar.SizeT.t | {
"end_col": 17,
"end_line": 25,
"start_col": 2,
"start_line": 25
} |
Prims.Pure | val lt (x y:t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x < v y))) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lt x y = U64.lt x y | val lt (x y:t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x < v y)))
let lt x y = | false | null | false | U64.lt x y | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"FStar.UInt64.lt",
"Prims.bool"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
let fits_lte x y = ()
#push-options "--z3rlimit 20"
let add x y = U64.add x y
let sub x y = U64.sub x y
let mul x y = U64.mul x y
let div x y =
let res = U64.div x y in
fits_lte (U64.v res) (U64.v x);
FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y);
assert (U64.v x / U64.v y <= U64.v x);
res
let rem x y = U64.rem x y
let gt x y = U64.gt x y | false | false | FStar.SizeT.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lt (x y:t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x < v y))) | [] | FStar.SizeT.lt | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure Prims.bool | {
"end_col": 23,
"end_line": 81,
"start_col": 13,
"start_line": 81
} |
Prims.Pure | val uint64_to_sizet (x:U64.t) : Pure t
(requires fits_u64)
(ensures fun y -> v y == U64.v x) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint64_to_sizet x = uint_to_t (U64.v x) | val uint64_to_sizet (x:U64.t) : Pure t
(requires fits_u64)
(ensures fun y -> v y == U64.v x)
let uint64_to_sizet x = | false | null | false | uint_to_t (U64.v x) | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.UInt64.t",
"FStar.SizeT.uint_to_t",
"FStar.UInt64.v",
"FStar.SizeT.t"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x) | false | false | FStar.SizeT.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_to_sizet (x:U64.t) : Pure t
(requires fits_u64)
(ensures fun y -> v y == U64.v x) | [] | FStar.SizeT.uint64_to_sizet | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.UInt64.t -> Prims.Pure FStar.SizeT.t | {
"end_col": 43,
"end_line": 63,
"start_col": 24,
"start_line": 63
} |
Prims.Pure | val uint32_to_sizet (x:U32.t) : Pure t
(requires fits_u32)
(ensures fun y -> v y == U32.v x) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let uint32_to_sizet x = uint_to_t (U32.v x) | val uint32_to_sizet (x:U32.t) : Pure t
(requires fits_u32)
(ensures fun y -> v y == U32.v x)
let uint32_to_sizet x = | false | null | false | uint_to_t (U32.v x) | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.UInt32.t",
"FStar.SizeT.uint_to_t",
"FStar.UInt32.v",
"FStar.SizeT.t"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x) | false | false | FStar.SizeT.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_to_sizet (x:U32.t) : Pure t
(requires fits_u32)
(ensures fun y -> v y == U32.v x) | [] | FStar.SizeT.uint32_to_sizet | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.UInt32.t -> Prims.Pure FStar.SizeT.t | {
"end_col": 43,
"end_line": 62,
"start_col": 24,
"start_line": 62
} |
Prims.Pure | val lte (x y: t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x <= v y))) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let lte x y = U64.lte x y | val lte (x y: t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x <= v y)))
let lte x y = | false | null | false | U64.lte x y | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"FStar.UInt64.lte",
"Prims.bool"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
let fits_lte x y = ()
#push-options "--z3rlimit 20"
let add x y = U64.add x y
let sub x y = U64.sub x y
let mul x y = U64.mul x y
let div x y =
let res = U64.div x y in
fits_lte (U64.v res) (U64.v x);
FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y);
assert (U64.v x / U64.v y <= U64.v x);
res
let rem x y = U64.rem x y
let gt x y = U64.gt x y
let gte x y = U64.gte x y | false | false | FStar.SizeT.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val lte (x y: t) : Pure bool
(requires True)
(ensures (fun z -> z == (v x <= v y))) | [] | FStar.SizeT.lte | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure Prims.bool | {
"end_col": 25,
"end_line": 82,
"start_col": 14,
"start_line": 82
} |
Prims.Pure | val of_u32 (x: U32.t) : Pure t
(requires fits_u32)
(ensures (fun y -> v y == U32.v x)) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let of_u32 (x: U32.t)
= uint_to_t (U32.v x) | val of_u32 (x: U32.t) : Pure t
(requires fits_u32)
(ensures (fun y -> v y == U32.v x))
let of_u32 (x: U32.t) = | false | null | false | uint_to_t (U32.v x) | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.UInt32.t",
"FStar.SizeT.uint_to_t",
"FStar.UInt32.v",
"FStar.SizeT.t"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= () | false | false | FStar.SizeT.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 of_u32 (x: U32.t) : Pure t
(requires fits_u32)
(ensures (fun y -> v y == U32.v x)) | [] | FStar.SizeT.of_u32 | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.UInt32.t -> Prims.Pure FStar.SizeT.t | {
"end_col": 23,
"end_line": 56,
"start_col": 4,
"start_line": 56
} |
Prims.Pure | val sizet_to_uint32 (x:t) : Pure U32.t
(requires True)
(ensures fun y -> U32.v y == v x % pow2 32) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x | val sizet_to_uint32 (x:t) : Pure U32.t
(requires True)
(ensures fun y -> U32.v y == v x % pow2 32)
let sizet_to_uint32 x = | false | null | false | FStar.Int.Cast.uint64_to_uint32 x | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"FStar.Int.Cast.uint64_to_uint32",
"FStar.UInt32.t"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x) | false | false | FStar.SizeT.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 sizet_to_uint32 (x:t) : Pure U32.t
(requires True)
(ensures fun y -> U32.v y == v x % pow2 32) | [] | FStar.SizeT.sizet_to_uint32 | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.SizeT.t -> Prims.Pure FStar.UInt32.t | {
"end_col": 57,
"end_line": 64,
"start_col": 24,
"start_line": 64
} |
Prims.Pure | val mul (x y: t) : Pure t
(requires (fits (v x * v y)))
(ensures (fun z -> v z == v x * v y)) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let mul x y = U64.mul x y | val mul (x y: t) : Pure t
(requires (fits (v x * v y)))
(ensures (fun z -> v z == v x * v y))
let mul x y = | false | null | false | U64.mul x y | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"FStar.UInt64.mul"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
let fits_lte x y = ()
#push-options "--z3rlimit 20"
let add x y = U64.add x y | false | false | FStar.SizeT.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val mul (x y: t) : Pure t
(requires (fits (v x * v y)))
(ensures (fun z -> v z == v x * v y)) | [] | FStar.SizeT.mul | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure FStar.SizeT.t | {
"end_col": 25,
"end_line": 71,
"start_col": 14,
"start_line": 71
} |
Prims.Pure | val add (x y: t) : Pure t
(requires (fits (v x + v y)))
(ensures (fun z -> v z == v x + v y)) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let add x y = U64.add x y | val add (x y: t) : Pure t
(requires (fits (v x + v y)))
(ensures (fun z -> v z == v x + v y))
let add x y = | false | null | false | U64.add x y | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"FStar.UInt64.add"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
let fits_lte x y = () | false | false | FStar.SizeT.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val add (x y: t) : Pure t
(requires (fits (v x + v y)))
(ensures (fun z -> v z == v x + v y)) | [] | FStar.SizeT.add | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | x: FStar.SizeT.t -> y: FStar.SizeT.t -> Prims.Pure FStar.SizeT.t | {
"end_col": 25,
"end_line": 69,
"start_col": 14,
"start_line": 69
} |
Prims.Pure | val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> mod_spec (v a) (v b) = v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let rem x y = U64.rem x y | val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> mod_spec (v a) (v b) = v c))
let rem x y = | false | null | false | U64.rem x y | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.int",
"FStar.SizeT.v",
"FStar.UInt64.rem"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
let fits_lte x y = ()
#push-options "--z3rlimit 20"
let add x y = U64.add x y
let sub x y = U64.sub x y
let mul x y = U64.mul x y
let div x y =
let res = U64.div x y in
fits_lte (U64.v res) (U64.v x);
FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y);
assert (U64.v x / U64.v y <= U64.v x); | false | false | FStar.SizeT.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val rem (a:t) (b:t{v b <> 0}) : Pure t
(requires True)
(ensures (fun c -> mod_spec (v a) (v b) = v c)) | [] | FStar.SizeT.rem | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.SizeT.t -> b: FStar.SizeT.t{FStar.SizeT.v b <> 0} -> Prims.Pure FStar.SizeT.t | {
"end_col": 25,
"end_line": 78,
"start_col": 14,
"start_line": 78
} |
Prims.Pure | val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c)) | [
{
"abbrev": true,
"full_module": "FStar.Int64",
"short_module": "I64"
},
{
"abbrev": false,
"full_module": "FStar.Ghost",
"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": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let div x y =
let res = U64.div x y in
fits_lte (U64.v res) (U64.v x);
FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y);
assert (U64.v x / U64.v y <= U64.v x);
res | val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c))
let div x y = | false | null | false | let res = U64.div x y in
fits_lte (U64.v res) (U64.v x);
FStar.Math.Lib.slash_decr_axiom (U64.v x) (U64.v y);
assert (U64.v x / U64.v y <= U64.v x);
res | {
"checked_file": "FStar.SizeT.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.UInt.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lib.fst.checked",
"FStar.Int64.fsti.checked",
"FStar.Int.Cast.fst.checked",
"FStar.Ghost.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.SizeT.fst"
} | [] | [
"FStar.SizeT.t",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.int",
"FStar.SizeT.v",
"Prims.unit",
"Prims._assert",
"Prims.op_LessThanOrEqual",
"Prims.op_Division",
"FStar.UInt64.v",
"FStar.Math.Lib.slash_decr_axiom",
"FStar.SizeT.fits_lte",
"FStar.UInt64.t",
"FStar.UInt64.div"
] | [] | module FStar.SizeT
open FStar.Ghost
module I64 = FStar.Int64
(* This is only intended as a model, but will be extracted natively by Krml
with the correct C semantics *)
(* We assume the existence of some lower bound on the size,
where the bound is at least 2^16 *)
assume
val bound : x:erased nat { x >= pow2 16 }
let t = x:U64.t { U64.v x < bound }
let fits x =
FStar.UInt.fits x U64.n == true /\
x < bound
let fits_at_least_16 _ = ()
let v x =
U64.v x
let uint_to_t x =
U64.uint_to_t x
let size_v_inj (x: t) = ()
let size_uint_to_t_inj (x: nat) = ()
/// These two predicates are only used for modeling purposes, and their definitions must
/// remain abstract to ensure they can only be introduced through a static assert.
/// We simply define them as True here
let fits_u32 = (reveal bound >= pow2 32) == true
let fits_u64 = (reveal bound == pow2 64)
let fits_u64_implies_fits_32 ()
: Lemma
(requires fits_u64)
(ensures fits_u32)
= ()
let fits_u32_implies_fits (x:nat)
: Lemma
(requires fits_u32 /\ x < pow2 32)
(ensures fits x)
= ()
let fits_u64_implies_fits (x:nat)
: Lemma
(requires fits_u64 /\ x < pow2 64)
(ensures fits x)
= ()
let of_u32 (x: U32.t)
= uint_to_t (U32.v x)
let of_u64 (x: U64.t)
= uint_to_t (U64.v x)
let uint16_to_sizet x = uint_to_t (U16.v x)
let uint32_to_sizet x = uint_to_t (U32.v x)
let uint64_to_sizet x = uint_to_t (U64.v x)
let sizet_to_uint32 x = FStar.Int.Cast.uint64_to_uint32 x
let fits_lte x y = ()
#push-options "--z3rlimit 20"
let add x y = U64.add x y
let sub x y = U64.sub x y | false | false | FStar.SizeT.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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val div (a:t) (b:t{v b <> 0}) : Pure t
(requires (True))
(ensures (fun c -> v a / v b = v c)) | [] | FStar.SizeT.div | {
"file_name": "ulib/FStar.SizeT.fst",
"git_rev": "f4cbb7a38d67eeb13fbdb2f4fb8a44a65cbcdc1f",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | a: FStar.SizeT.t -> b: FStar.SizeT.t{FStar.SizeT.v b <> 0} -> Prims.Pure FStar.SizeT.t | {
"end_col": 5,
"end_line": 77,
"start_col": 13,
"start_line": 72
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:ME.bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (lbignum t len)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b)) | let bn_exp_almost_mont_st (t: limb_t) (len: BN.bn_len t) = | false | null | false |
n: lbignum t len ->
mu: limb t {BM.bn_mont_pre n mu} ->
aM: ME.bn_mont_t n ->
bBits: size_nat ->
b: lbignum t (blocks0 bBits (bits t)) {bn_v b < pow2 bBits}
-> Pure (lbignum t len)
(requires True)
(ensures
fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b)) | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Prims.l_True",
"Prims.eq2",
"Prims.int",
"Prims.op_Modulus",
"Lib.Exponentiation.Definition.pow",
"Lib.NatMod.nat_mod",
"Lib.Exponentiation.Definition.comm_monoid",
"Hacl.Spec.Exponentiation.Lemmas.mk_nat_mont_ll_comm_monoid",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (lbignum t len) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = amm_refl n;
}
val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one
val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_mul #t #len n mu aM bM =
let c = BA.bn_almost_mont_mul n mu aM bM in
BA.bn_almost_mont_mul_lemma n mu aM bM;
bn_eval_bound aM len;
bn_eval_bound bM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM);
c
val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_sqr #t #len n mu aM =
let c = BA.bn_almost_mont_sqr n mu aM in
BA.bn_almost_mont_sqr_lemma n mu aM;
bn_eval_bound aM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM);
c
let mk_bn_almost_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (lbignum t len) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_almost_mont_one #t #len n mu;
SE.mul = bn_almost_mont_mul #t #len n mu;
SE.sqr = bn_almost_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
noextract | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_exp_almost_mont_st : t: Hacl.Spec.Bignum.Definitions.limb_t -> len: Hacl.Spec.Bignum.bn_len t -> Type0 | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | t: Hacl.Spec.Bignum.Definitions.limb_t -> len: Hacl.Spec.Bignum.bn_len t -> Type0 | {
"end_col": 54,
"end_line": 115,
"start_col": 4,
"start_line": 106
} |
|
Prims.Tot | val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one | val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ = | false | null | false | let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"Lib.NatMod.nat_mod",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Hacl.Spec.Bignum.AlmostMontExponentiation.amm_refl",
"Hacl.Spec.Exponentiation.Lemmas.mont_one_ll",
"Lib.IntTypes.bits",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"FStar.Math.Lemmas.small_mod",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_one"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (lbignum t len) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = amm_refl n;
}
val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_almost_mont_one | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Hacl.Spec.Bignum.Definitions.lbignum t len ->
mu: Hacl.Spec.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu}
-> Spec.Exponentiation.one_st (Hacl.Spec.Bignum.Definitions.lbignum t len)
(Hacl.Spec.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid n mu) | {
"end_col": 5,
"end_line": 55,
"start_col": 39,
"start_line": 50
} |
Prims.Tot | val amm_refl (#t: limb_t) (#len: BN.bn_len t) (n: lbignum t len {0 < bn_v n}) (x: lbignum t len)
: Lib.NatMod.nat_mod (bn_v n) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n | val amm_refl (#t: limb_t) (#len: BN.bn_len t) (n: lbignum t len {0 < bn_v n}) (x: lbignum t len)
: Lib.NatMod.nat_mod (bn_v n)
let amm_refl (#t: limb_t) (#len: BN.bn_len t) (n: lbignum t len {0 < bn_v n}) (x: lbignum t len)
: Lib.NatMod.nat_mod (bn_v n) = | false | null | false | bn_v x % bn_v n | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.op_Modulus",
"Lib.NatMod.nat_mod"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n) | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.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 amm_refl (#t: limb_t) (#len: BN.bn_len t) (n: lbignum t len {0 < bn_v n}) (x: lbignum t len)
: Lib.NatMod.nat_mod (bn_v n) | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.amm_refl | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Hacl.Spec.Bignum.Definitions.lbignum t len {0 < Hacl.Spec.Bignum.Definitions.bn_v n} ->
x: Hacl.Spec.Bignum.Definitions.lbignum t len
-> Lib.NatMod.nat_mod (Hacl.Spec.Bignum.Definitions.bn_v n) | {
"end_col": 17,
"end_line": 28,
"start_col": 2,
"start_line": 28
} |
Prims.Tot | val bn_exp_almost_mont_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_exp_almost_mont_consttime #t #len n mu aM bBits b =
if bBits < ME.bn_exp_mont_consttime_threshold then
bn_exp_almost_mont_bm_consttime n mu aM bBits b
else
bn_exp_almost_mont_fw 4 n mu aM bBits b | val bn_exp_almost_mont_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_consttime #t #len n mu aM bBits b = | false | null | false | if bBits < ME.bn_exp_mont_consttime_threshold
then bn_exp_almost_mont_bm_consttime n mu aM bBits b
else bn_exp_almost_mont_fw 4 n mu aM bBits b | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_consttime_threshold",
"Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_consttime",
"Prims.bool",
"Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (lbignum t len) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = amm_refl n;
}
val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one
val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_mul #t #len n mu aM bM =
let c = BA.bn_almost_mont_mul n mu aM bM in
BA.bn_almost_mont_mul_lemma n mu aM bM;
bn_eval_bound aM len;
bn_eval_bound bM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM);
c
val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_sqr #t #len n mu aM =
let c = BA.bn_almost_mont_sqr n mu aM in
BA.bn_almost_mont_sqr_lemma n mu aM;
bn_eval_bound aM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM);
c
let mk_bn_almost_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (lbignum t len) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_almost_mont_one #t #len n mu;
SE.mul = bn_almost_mont_mul #t #len n mu;
SE.sqr = bn_almost_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
noextract
let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:ME.bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (lbignum t len)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level
val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
let resM = SE.exp_rl k1 aM bBits (bn_v b) in
//assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b));
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
//assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b));
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
resM
val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b)
val bn_exp_almost_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_almost_mont_st t len
let bn_exp_almost_mont_fw #t #len l n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
SE.exp_fw_lemma k1 aM bBits (bn_v b) l;
LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM % bn_v n) bBits (bn_v b) l;
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
SE.exp_fw k1 aM bBits (bn_v b) l
val bn_exp_almost_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_vartime #t #len n mu aM bBits b =
if bBits < ME.bn_exp_mont_vartime_threshold then
bn_exp_almost_mont_bm_vartime n mu aM bBits b
else
bn_exp_almost_mont_fw 4 n mu aM bBits b
val bn_exp_almost_mont_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_exp_almost_mont_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_consttime | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len | {
"end_col": 43,
"end_line": 172,
"start_col": 2,
"start_line": 169
} |
Prims.Tot | val bn_exp_almost_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_exp_almost_mont_vartime #t #len n mu aM bBits b =
if bBits < ME.bn_exp_mont_vartime_threshold then
bn_exp_almost_mont_bm_vartime n mu aM bBits b
else
bn_exp_almost_mont_fw 4 n mu aM bBits b | val bn_exp_almost_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_vartime #t #len n mu aM bBits b = | false | null | false | if bBits < ME.bn_exp_mont_vartime_threshold
then bn_exp_almost_mont_bm_vartime n mu aM bBits b
else bn_exp_almost_mont_fw 4 n mu aM bBits b | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Hacl.Spec.Bignum.MontExponentiation.bn_exp_mont_vartime_threshold",
"Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_vartime",
"Prims.bool",
"Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (lbignum t len) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = amm_refl n;
}
val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one
val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_mul #t #len n mu aM bM =
let c = BA.bn_almost_mont_mul n mu aM bM in
BA.bn_almost_mont_mul_lemma n mu aM bM;
bn_eval_bound aM len;
bn_eval_bound bM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM);
c
val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_sqr #t #len n mu aM =
let c = BA.bn_almost_mont_sqr n mu aM in
BA.bn_almost_mont_sqr_lemma n mu aM;
bn_eval_bound aM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM);
c
let mk_bn_almost_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (lbignum t len) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_almost_mont_one #t #len n mu;
SE.mul = bn_almost_mont_mul #t #len n mu;
SE.sqr = bn_almost_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
noextract
let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:ME.bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (lbignum t len)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level
val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
let resM = SE.exp_rl k1 aM bBits (bn_v b) in
//assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b));
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
//assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b));
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
resM
val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b)
val bn_exp_almost_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_almost_mont_st t len
let bn_exp_almost_mont_fw #t #len l n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
SE.exp_fw_lemma k1 aM bBits (bn_v b) l;
LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM % bn_v n) bBits (bn_v b) l;
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
SE.exp_fw k1 aM bBits (bn_v b) l
val bn_exp_almost_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_exp_almost_mont_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_vartime | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len | {
"end_col": 43,
"end_line": 164,
"start_col": 2,
"start_line": 161
} |
Prims.Tot | val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_almost_mont_mul #t #len n mu aM bM =
let c = BA.bn_almost_mont_mul n mu aM bM in
BA.bn_almost_mont_mul_lemma n mu aM bM;
bn_eval_bound aM len;
bn_eval_bound bM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM);
c | val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_mul #t #len n mu aM bM = | false | null | false | let c = BA.bn_almost_mont_mul n mu aM bM in
BA.bn_almost_mont_mul_lemma n mu aM bM;
bn_eval_bound aM len;
bn_eval_bound bM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM);
c | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Prims.unit",
"Hacl.Spec.AlmostMontgomery.Lemmas.almost_mont_mul_is_mont_mul_lemma",
"Lib.IntTypes.bits",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_mul_lemma",
"Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_mul"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (lbignum t len) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = amm_refl n;
}
val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one
val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_almost_mont_mul | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Hacl.Spec.Bignum.Definitions.lbignum t len ->
mu: Hacl.Spec.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu}
-> Spec.Exponentiation.mul_st (Hacl.Spec.Bignum.Definitions.lbignum t len)
(Hacl.Spec.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid n mu) | {
"end_col": 3,
"end_line": 71,
"start_col": 43,
"start_line": 65
} |
Prims.Tot | val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_almost_mont_sqr #t #len n mu aM =
let c = BA.bn_almost_mont_sqr n mu aM in
BA.bn_almost_mont_sqr_lemma n mu aM;
bn_eval_bound aM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM);
c | val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_sqr #t #len n mu aM = | false | null | false | let c = BA.bn_almost_mont_sqr n mu aM in
BA.bn_almost_mont_sqr_lemma n mu aM;
bn_eval_bound aM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM);
c | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Prims.unit",
"Hacl.Spec.AlmostMontgomery.Lemmas.almost_mont_mul_is_mont_mul_lemma",
"Lib.IntTypes.bits",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_sqr_lemma",
"Hacl.Spec.Bignum.AlmostMontgomery.bn_almost_mont_sqr"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (lbignum t len) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = amm_refl n;
}
val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one
val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_mul #t #len n mu aM bM =
let c = BA.bn_almost_mont_mul n mu aM bM in
BA.bn_almost_mont_mul_lemma n mu aM bM;
bn_eval_bound aM len;
bn_eval_bound bM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM);
c
val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu) | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_almost_mont_sqr | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
n: Hacl.Spec.Bignum.Definitions.lbignum t len ->
mu: Hacl.Spec.Bignum.Definitions.limb t {Hacl.Spec.Bignum.Montgomery.bn_mont_pre n mu}
-> Spec.Exponentiation.sqr_st (Hacl.Spec.Bignum.Definitions.lbignum t len)
(Hacl.Spec.Bignum.AlmostMontExponentiation.mk_to_nat_mont_ll_comm_monoid n mu) | {
"end_col": 3,
"end_line": 86,
"start_col": 40,
"start_line": 81
} |
Prims.Tot | val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
let resM = SE.exp_rl k1 aM bBits (bn_v b) in
//assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b));
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
//assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b));
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
resM | val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b = | false | null | false | let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
let resM = SE.exp_rl k1 aM bBits (bn_v b) in
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
resM | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Prims.unit",
"Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Lib.Exponentiation.exp_rl_lemma",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__to",
"Prims.op_Modulus",
"Spec.Exponentiation.exp_rl_lemma",
"Spec.Exponentiation.exp_rl",
"Lib.Exponentiation.Definition.comm_monoid",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid",
"Spec.Exponentiation.concrete_ops",
"Hacl.Spec.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (lbignum t len) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = amm_refl n;
}
val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one
val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_mul #t #len n mu aM bM =
let c = BA.bn_almost_mont_mul n mu aM bM in
BA.bn_almost_mont_mul_lemma n mu aM bM;
bn_eval_bound aM len;
bn_eval_bound bM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM);
c
val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_sqr #t #len n mu aM =
let c = BA.bn_almost_mont_sqr n mu aM in
BA.bn_almost_mont_sqr_lemma n mu aM;
bn_eval_bound aM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM);
c
let mk_bn_almost_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (lbignum t len) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_almost_mont_one #t #len n mu;
SE.mul = bn_almost_mont_mul #t #len n mu;
SE.sqr = bn_almost_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
noextract
let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:ME.bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (lbignum t len)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_vartime | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len | {
"end_col": 6,
"end_line": 130,
"start_col": 59,
"start_line": 120
} |
Prims.Tot | val bn_exp_almost_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_almost_mont_st t len | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_exp_almost_mont_fw #t #len l n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
SE.exp_fw_lemma k1 aM bBits (bn_v b) l;
LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM % bn_v n) bBits (bn_v b) l;
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
SE.exp_fw k1 aM bBits (bn_v b) l | val bn_exp_almost_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_almost_mont_st t len
let bn_exp_almost_mont_fw #t #len l n mu aM bBits b = | false | null | false | let k1 = mk_bn_almost_mont_concrete_ops n mu in
SE.exp_fw_lemma k1 aM bBits (bn_v b) l;
LE.exp_fw_lemma k1.SE.to.SE.comm_monoid (bn_v aM % bn_v n) bBits (bn_v b) l;
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
SE.exp_fw k1 aM bBits (bn_v b) l | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Lib.IntTypes.size_pos",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.bits",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Prims.pow2",
"Lib.IntTypes.max_size_t",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Spec.Exponentiation.exp_fw",
"Prims.unit",
"Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Lib.Exponentiation.exp_fw_lemma",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__to",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid",
"Prims.op_Modulus",
"Spec.Exponentiation.exp_fw_lemma",
"Spec.Exponentiation.concrete_ops",
"Hacl.Spec.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (lbignum t len) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = amm_refl n;
}
val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one
val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_mul #t #len n mu aM bM =
let c = BA.bn_almost_mont_mul n mu aM bM in
BA.bn_almost_mont_mul_lemma n mu aM bM;
bn_eval_bound aM len;
bn_eval_bound bM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM);
c
val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_sqr #t #len n mu aM =
let c = BA.bn_almost_mont_sqr n mu aM in
BA.bn_almost_mont_sqr_lemma n mu aM;
bn_eval_bound aM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM);
c
let mk_bn_almost_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (lbignum t len) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_almost_mont_one #t #len n mu;
SE.mul = bn_almost_mont_mul #t #len n mu;
SE.sqr = bn_almost_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
noextract
let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:ME.bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (lbignum t len)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level
val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
let resM = SE.exp_rl k1 aM bBits (bn_v b) in
//assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b));
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
//assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b));
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
resM
val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b)
val bn_exp_almost_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_almost_mont_st t len | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_exp_almost_mont_fw:
#t:limb_t
-> #len:BN.bn_len t
-> l:size_pos{l < bits t /\ pow2 l * len <= max_size_t} ->
bn_exp_almost_mont_st t len | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_fw | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | l: Lib.IntTypes.size_pos{l < Lib.IntTypes.bits t /\ Prims.pow2 l * len <= Lib.IntTypes.max_size_t}
-> Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len | {
"end_col": 34,
"end_line": 156,
"start_col": 53,
"start_line": 151
} |
Prims.Tot | val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.MontExponentiation",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.AlmostMontgomery",
"short_module": "BA"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.AlmostMontgomery.Lemmas",
"short_module": "AM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Exponentiation.Lemmas",
"short_module": "E"
},
{
"abbrev": true,
"full_module": "Spec.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Lib.Exponentiation",
"short_module": "LE"
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Spec.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b) | val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_consttime #t #len n mu aM bBits b = | false | null | false | let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
SE.exp_mont_ladder_swap_lemma k1 aM bBits (bn_v b);
LE.exp_mont_ladder_swap_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
LE.exp_mont_ladder_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
SE.exp_mont_ladder_swap k1 aM bBits (bn_v b) | {
"checked_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst.checked",
"dependencies": [
"Spec.Exponentiation.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Exponentiation.fsti.checked",
"Hacl.Spec.Exponentiation.Lemmas.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.MontExponentiation.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.AlmostMontgomery.fsti.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Spec.AlmostMontgomery.Lemmas.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Spec.Bignum.AlmostMontExponentiation.fst"
} | [
"total"
] | [
"Hacl.Spec.Bignum.Definitions.limb_t",
"Hacl.Spec.Bignum.bn_len",
"Hacl.Spec.Bignum.Definitions.lbignum",
"Hacl.Spec.Bignum.Definitions.limb",
"Hacl.Spec.Bignum.Montgomery.bn_mont_pre",
"Hacl.Spec.Bignum.MontExponentiation.bn_mont_t",
"Lib.IntTypes.size_nat",
"Hacl.Spec.Bignum.Definitions.blocks0",
"Lib.IntTypes.bits",
"Prims.b2t",
"Prims.op_LessThan",
"Hacl.Spec.Bignum.Definitions.bn_v",
"Prims.pow2",
"Spec.Exponentiation.exp_mont_ladder_swap",
"Prims.unit",
"Hacl.Spec.Exponentiation.Lemmas.pow_nat_mont_ll_mod_base",
"Lib.IntTypes.v",
"Lib.IntTypes.SEC",
"Lib.Exponentiation.exp_mont_ladder_lemma",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__a_spec",
"Spec.Exponentiation.__proj__Mkconcrete_ops__item__to",
"Prims.op_Modulus",
"Lib.Exponentiation.exp_mont_ladder_swap_lemma",
"Spec.Exponentiation.exp_mont_ladder_swap_lemma",
"Lib.Exponentiation.Definition.comm_monoid",
"Spec.Exponentiation.__proj__Mkto_comm_monoid__item__comm_monoid",
"Spec.Exponentiation.concrete_ops",
"Hacl.Spec.Bignum.AlmostMontExponentiation.mk_bn_almost_mont_concrete_ops"
] | [] | module Hacl.Spec.Bignum.AlmostMontExponentiation
open FStar.Mul
open Lib.IntTypes
open Lib.Sequence
open Hacl.Spec.Bignum.Definitions
module LE = Lib.Exponentiation
module SE = Spec.Exponentiation
module E = Hacl.Spec.Exponentiation.Lemmas
module AM = Hacl.Spec.AlmostMontgomery.Lemmas
module BN = Hacl.Spec.Bignum
module BM = Hacl.Spec.Bignum.Montgomery
module BA = Hacl.Spec.Bignum.AlmostMontgomery
module ME = Hacl.Spec.Bignum.MontExponentiation
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
let amm_refl
(#t:limb_t) (#len:BN.bn_len t)
(n:lbignum t len{0 < bn_v n})
(x:lbignum t len) : Lib.NatMod.nat_mod (bn_v n)
=
bn_v x % bn_v n
let mk_to_nat_mont_ll_comm_monoid
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.to_comm_monoid (lbignum t len) =
{
SE.a_spec = Lib.NatMod.nat_mod (bn_v n);
SE.comm_monoid = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu);
SE.refl = amm_refl n;
}
val bn_almost_mont_one:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.one_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_one #t #len n mu _ =
let one = ME.bn_mont_one n mu () in
assert (bn_v one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
Math.Lemmas.small_mod (bn_v one) (bn_v n);
assert (amm_refl n one == E.mont_one_ll (bits t) len (bn_v n) (v mu));
one
val bn_almost_mont_mul:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.mul_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_mul #t #len n mu aM bM =
let c = BA.bn_almost_mont_mul n mu aM bM in
BA.bn_almost_mont_mul_lemma n mu aM bM;
bn_eval_bound aM len;
bn_eval_bound bM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v bM);
c
val bn_almost_mont_sqr:
#t:limb_t
-> #len:BN.bn_len t
-> n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu} ->
SE.sqr_st (lbignum t len) (mk_to_nat_mont_ll_comm_monoid n mu)
let bn_almost_mont_sqr #t #len n mu aM =
let c = BA.bn_almost_mont_sqr n mu aM in
BA.bn_almost_mont_sqr_lemma n mu aM;
bn_eval_bound aM len;
AM.almost_mont_mul_is_mont_mul_lemma (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v aM);
c
let mk_bn_almost_mont_concrete_ops
(#t:limb_t)
(#len:BN.bn_len t)
(n:lbignum t len)
(mu:limb t{BM.bn_mont_pre n mu})
: SE.concrete_ops (lbignum t len) =
{
SE.to = mk_to_nat_mont_ll_comm_monoid n mu;
SE.one = bn_almost_mont_one #t #len n mu;
SE.mul = bn_almost_mont_mul #t #len n mu;
SE.sqr = bn_almost_mont_sqr #t #len n mu;
}
///////////////////////////////////////////////////////////////////////////////
noextract
let bn_exp_almost_mont_st (t:limb_t) (len:BN.bn_len t) =
n:lbignum t len
-> mu:limb t{BM.bn_mont_pre n mu}
-> aM:ME.bn_mont_t n
-> bBits:size_nat
-> b:lbignum t (blocks0 bBits (bits t)){bn_v b < pow2 bBits} ->
Pure (lbignum t len)
(requires True)
(ensures fun resM ->
let k = E.mk_nat_mont_ll_comm_monoid (bits t) len (bn_v n) (v mu) in
bn_v resM % bn_v n == LE.pow k (bn_v aM) (bn_v b))
// no diff between vartime and consttime at the spec level
val bn_exp_almost_mont_bm_vartime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len
let bn_exp_almost_mont_bm_vartime #t #len n mu aM bBits b =
let k1 = mk_bn_almost_mont_concrete_ops n mu in
let k = k1.SE.to.SE.comm_monoid in
let resM = SE.exp_rl k1 aM bBits (bn_v b) in
//assert (bn_v resM % bn_v n == LE.exp_rl k (bn_v aM % bn_v n) bBits (bn_v b));
SE.exp_rl_lemma k1 aM bBits (bn_v b);
LE.exp_rl_lemma k (bn_v aM % bn_v n) bBits (bn_v b);
//assert (bn_v resM % bn_v n == LE.pow k (bn_v aM % bn_v n) (bn_v b));
E.pow_nat_mont_ll_mod_base (bits t) len (bn_v n) (v mu) (bn_v aM) (bn_v b);
resM | false | false | Hacl.Spec.Bignum.AlmostMontExponentiation.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bn_exp_almost_mont_bm_consttime: #t:limb_t -> #len:BN.bn_len t -> bn_exp_almost_mont_st t len | [] | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_bm_consttime | {
"file_name": "code/bignum/Hacl.Spec.Bignum.AlmostMontExponentiation.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | Hacl.Spec.Bignum.AlmostMontExponentiation.bn_exp_almost_mont_st t len | {
"end_col": 46,
"end_line": 142,
"start_col": 61,
"start_line": 134
} |
Prims.Tot | [
{
"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 done = return () | let done = | false | null | false | return () | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.return",
"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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind | false | true | Steel.Channel.Protocol.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 done : Steel.Channel.Protocol.protocol Prims.unit | [] | Steel.Channel.Protocol.done | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Steel.Channel.Protocol.protocol Prims.unit | {
"end_col": 20,
"end_line": 68,
"start_col": 11,
"start_line": 68
} |
|
Prims.GTot | val finished (p: protocol 'a) : GTot bool | [
{
"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 finished (p:protocol 'a) : GTot bool = Return? (hnf p) | val finished (p: protocol 'a) : GTot bool
let finished (p: protocol 'a) : GTot bool = | false | null | false | Return? (hnf p) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"sometrivial"
] | [
"Steel.Channel.Protocol.protocol",
"Steel.Channel.Protocol.uu___is_Return",
"Steel.Channel.Protocol.hnf",
"Prims.bool"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p | false | false | Steel.Channel.Protocol.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 finished (p: protocol 'a) : GTot bool | [] | Steel.Channel.Protocol.finished | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Channel.Protocol.protocol 'a -> Prims.GTot Prims.bool | {
"end_col": 58,
"end_line": 86,
"start_col": 43,
"start_line": 86
} |
Prims.Tot | [
{
"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 protocol a = p:prot a { ok p } | let protocol a = | false | null | false | p: prot a {ok p} | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.prot",
"Steel.Channel.Protocol.ok"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k | false | true | Steel.Channel.Protocol.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 protocol : a: Type0 -> Type | [] | Steel.Channel.Protocol.protocol | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | a: Type0 -> Type | {
"end_col": 34,
"end_line": 35,
"start_col": 17,
"start_line": 35
} |
|
Prims.Tot | val xy:prot unit | [
{
"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 xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return () | val xy:prot unit
let xy:prot unit = | false | null | false | let^ x = send int in
let^ y = recv (y: int{y > x}) in
return () | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.op_let_Hat",
"Prims.int",
"Prims.unit",
"Steel.Channel.Protocol.send",
"Prims.b2t",
"Prims.op_GreaterThan",
"Steel.Channel.Protocol.recv",
"Steel.Channel.Protocol.return",
"Steel.Channel.Protocol.protocol"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *) | false | true | Steel.Channel.Protocol.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 xy:prot unit | [] | Steel.Channel.Protocol.xy | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | Steel.Channel.Protocol.prot Prims.unit | {
"end_col": 11,
"end_line": 78,
"start_col": 2,
"start_line": 76
} |
Prims.GTot | [
{
"abbrev": true,
"full_module": "FStar.ReflexiveTransitiveClosure",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"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 more (p:protocol unit) = more_msgs p | let more (p: protocol unit) = | false | null | false | more_msgs p | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"sometrivial"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"Steel.Channel.Protocol.more_msgs",
"Prims.bool"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m)
let rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x))
(decreases t)
= match t with
| Message _ x _ (Waiting _) -> (| from , x, () |)
| Message _ _ _ tail -> last_step_of tail
noeq
type partial_trace_of (p:protocol unit) = {
to:protocol unit;
tr:trace p to
}
module P = FStar.Preorder
module R = FStar.ReflexiveTransitiveClosure
let next (#p:protocol unit) : P.relation (partial_trace_of p) =
fun (t0 t1: partial_trace_of p) ->
more_msgs t0.to /\
(exists (msg:next_msg_t t0.to).
t1.to == step t0.to msg /\
t1.tr == extend t0.tr msg)
let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) =
R.closure (next #p)
let extend_partial_trace (#p:protocol unit)
(x:partial_trace_of p)
(msg:next_msg_t x.to{more_msgs x.to})
: Tot (y:partial_trace_of p{x `extended_to` y})
= { to=_; tr=extend x.tr msg} | false | false | Steel.Channel.Protocol.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 more : p: Steel.Channel.Protocol.protocol Prims.unit -> Prims.GTot Prims.bool | [] | Steel.Channel.Protocol.more | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Channel.Protocol.protocol Prims.unit -> Prims.GTot Prims.bool | {
"end_col": 40,
"end_line": 148,
"start_col": 29,
"start_line": 148
} |
|
Prims.GTot | val more_msgs (p: protocol 'a) : GTot bool | [
{
"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 more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) | val more_msgs (p: protocol 'a) : GTot bool
let more_msgs (p: protocol 'a) : GTot bool = | false | null | false | Msg? (hnf p) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"sometrivial"
] | [
"Steel.Channel.Protocol.protocol",
"Steel.Channel.Protocol.uu___is_Msg",
"Steel.Channel.Protocol.hnf",
"Prims.bool"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p | false | false | Steel.Channel.Protocol.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 more_msgs (p: protocol 'a) : GTot bool | [] | Steel.Channel.Protocol.more_msgs | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Channel.Protocol.protocol 'a -> Prims.GTot Prims.bool | {
"end_col": 56,
"end_line": 87,
"start_col": 44,
"start_line": 87
} |
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.ReflexiveTransitiveClosure",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"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 until #p (tr:partial_trace_of p) = tr.to | let until #p (tr: partial_trace_of p) = | false | null | false | tr.to | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"Steel.Channel.Protocol.partial_trace_of",
"Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__to"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m)
let rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x))
(decreases t)
= match t with
| Message _ x _ (Waiting _) -> (| from , x, () |)
| Message _ _ _ tail -> last_step_of tail
noeq
type partial_trace_of (p:protocol unit) = {
to:protocol unit;
tr:trace p to
}
module P = FStar.Preorder
module R = FStar.ReflexiveTransitiveClosure
let next (#p:protocol unit) : P.relation (partial_trace_of p) =
fun (t0 t1: partial_trace_of p) ->
more_msgs t0.to /\
(exists (msg:next_msg_t t0.to).
t1.to == step t0.to msg /\
t1.tr == extend t0.tr msg)
let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) =
R.closure (next #p)
let extend_partial_trace (#p:protocol unit)
(x:partial_trace_of p)
(msg:next_msg_t x.to{more_msgs x.to})
: Tot (y:partial_trace_of p{x `extended_to` y})
= { to=_; tr=extend x.tr msg}
let more (p:protocol unit) = more_msgs p
let tag_of (p:protocol unit{more p}) : GTot tag = Msg?._0 (hnf p)
let msg_t (p:protocol unit) = next_msg_t p | false | false | Steel.Channel.Protocol.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 until : tr: Steel.Channel.Protocol.partial_trace_of p -> Steel.Channel.Protocol.protocol Prims.unit | [] | Steel.Channel.Protocol.until | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | tr: Steel.Channel.Protocol.partial_trace_of p -> Steel.Channel.Protocol.protocol Prims.unit | {
"end_col": 44,
"end_line": 152,
"start_col": 39,
"start_line": 152
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.ReflexiveTransitiveClosure",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"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 msg_t (p:protocol unit) = next_msg_t p | let msg_t (p: protocol unit) = | false | null | false | next_msg_t p | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"Steel.Channel.Protocol.next_msg_t"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m)
let rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x))
(decreases t)
= match t with
| Message _ x _ (Waiting _) -> (| from , x, () |)
| Message _ _ _ tail -> last_step_of tail
noeq
type partial_trace_of (p:protocol unit) = {
to:protocol unit;
tr:trace p to
}
module P = FStar.Preorder
module R = FStar.ReflexiveTransitiveClosure
let next (#p:protocol unit) : P.relation (partial_trace_of p) =
fun (t0 t1: partial_trace_of p) ->
more_msgs t0.to /\
(exists (msg:next_msg_t t0.to).
t1.to == step t0.to msg /\
t1.tr == extend t0.tr msg)
let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) =
R.closure (next #p)
let extend_partial_trace (#p:protocol unit)
(x:partial_trace_of p)
(msg:next_msg_t x.to{more_msgs x.to})
: Tot (y:partial_trace_of p{x `extended_to` y})
= { to=_; tr=extend x.tr msg}
let more (p:protocol unit) = more_msgs p | false | true | Steel.Channel.Protocol.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 msg_t : p: Steel.Channel.Protocol.protocol Prims.unit -> Type0 | [] | Steel.Channel.Protocol.msg_t | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Channel.Protocol.protocol Prims.unit -> Type0 | {
"end_col": 42,
"end_line": 150,
"start_col": 30,
"start_line": 150
} |
|
Prims.Tot | [
{
"abbrev": true,
"full_module": "FStar.ReflexiveTransitiveClosure",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"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 extension_of #p (tr:partial_trace_of p) = ts:partial_trace_of p{tr `extended_to` ts} | let extension_of #p (tr: partial_trace_of p) = | false | null | false | ts: partial_trace_of p {tr `extended_to` ts} | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"Steel.Channel.Protocol.partial_trace_of",
"Steel.Channel.Protocol.extended_to"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m)
let rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x))
(decreases t)
= match t with
| Message _ x _ (Waiting _) -> (| from , x, () |)
| Message _ _ _ tail -> last_step_of tail
noeq
type partial_trace_of (p:protocol unit) = {
to:protocol unit;
tr:trace p to
}
module P = FStar.Preorder
module R = FStar.ReflexiveTransitiveClosure
let next (#p:protocol unit) : P.relation (partial_trace_of p) =
fun (t0 t1: partial_trace_of p) ->
more_msgs t0.to /\
(exists (msg:next_msg_t t0.to).
t1.to == step t0.to msg /\
t1.tr == extend t0.tr msg)
let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) =
R.closure (next #p)
let extend_partial_trace (#p:protocol unit)
(x:partial_trace_of p)
(msg:next_msg_t x.to{more_msgs x.to})
: Tot (y:partial_trace_of p{x `extended_to` y})
= { to=_; tr=extend x.tr msg}
let more (p:protocol unit) = more_msgs p
let tag_of (p:protocol unit{more p}) : GTot tag = Msg?._0 (hnf p) | false | false | Steel.Channel.Protocol.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 extension_of : tr: Steel.Channel.Protocol.partial_trace_of p -> Type | [] | Steel.Channel.Protocol.extension_of | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | tr: Steel.Channel.Protocol.partial_trace_of p -> Type | {
"end_col": 88,
"end_line": 151,
"start_col": 46,
"start_line": 151
} |
|
Prims.Tot | [
{
"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 flip_tag = function
| Send -> Recv
| Recv -> Send | let flip_tag = | false | null | false | function
| Send -> Recv
| Recv -> Send | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.tag",
"Steel.Channel.Protocol.Recv",
"Steel.Channel.Protocol.Send"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p } | false | true | Steel.Channel.Protocol.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 flip_tag : _: Steel.Channel.Protocol.tag -> Steel.Channel.Protocol.tag | [] | Steel.Channel.Protocol.flip_tag | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | _: Steel.Channel.Protocol.tag -> Steel.Channel.Protocol.tag | {
"end_col": 16,
"end_line": 40,
"start_col": 15,
"start_line": 38
} |
|
Prims.Tot | val return (#a: Type) (x: a) : protocol a | [
{
"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 return (#a:Type) (x:a) : protocol a = Return x | val return (#a: Type) (x: a) : protocol a
let return (#a: Type) (x: a) : protocol a = | false | null | false | Return x | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.Return",
"Steel.Channel.Protocol.protocol"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind | false | false | Steel.Channel.Protocol.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val return (#a: Type) (x: a) : protocol a | [] | Steel.Channel.Protocol.return | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | x: a -> Steel.Channel.Protocol.protocol a | {
"end_col": 50,
"end_line": 67,
"start_col": 42,
"start_line": 67
} |
Prims.Tot | [
{
"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 rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k | let rec ok #a (p: prot a) = | false | null | false | match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.prot",
"Prims.l_True",
"Steel.Channel.Protocol.tag",
"Prims.l_Forall",
"Steel.Channel.Protocol.ok",
"Prims.bool",
"Prims.l_and",
"Prims.b2t",
"Steel.Channel.Protocol.uu___is_Msg"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a | false | false | Steel.Channel.Protocol.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 ok : p: Steel.Channel.Protocol.prot a -> Type0 | [
"recursion"
] | Steel.Channel.Protocol.ok | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Channel.Protocol.prot a -> Type0 | {
"end_col": 41,
"end_line": 33,
"start_col": 2,
"start_line": 30
} |
|
Prims.Tot | val recv (t: Type) : protocol t | [
{
"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 recv (t:Type) : protocol t = Msg Recv t (fun x -> return x) | val recv (t: Type) : protocol t
let recv (t: Type) : protocol t = | false | null | false | Msg Recv t (fun x -> return x) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.Msg",
"Steel.Channel.Protocol.Recv",
"Steel.Channel.Protocol.return",
"Steel.Channel.Protocol.prot",
"Steel.Channel.Protocol.protocol"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return () | false | false | Steel.Channel.Protocol.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 recv (t: Type) : protocol t | [] | Steel.Channel.Protocol.recv | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: Type0 -> Steel.Channel.Protocol.protocol t | {
"end_col": 63,
"end_line": 70,
"start_col": 33,
"start_line": 70
} |
Prims.Tot | val send (t: Type) : protocol t | [
{
"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 send (t:Type) : protocol t = Msg Send t (fun x -> return x) | val send (t: Type) : protocol t
let send (t: Type) : protocol t = | false | null | false | Msg Send t (fun x -> return x) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.Msg",
"Steel.Channel.Protocol.Send",
"Steel.Channel.Protocol.return",
"Steel.Channel.Protocol.prot",
"Steel.Channel.Protocol.protocol"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x | false | false | Steel.Channel.Protocol.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 send (t: Type) : protocol t | [] | Steel.Channel.Protocol.send | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: Type0 -> Steel.Channel.Protocol.protocol t | {
"end_col": 63,
"end_line": 69,
"start_col": 33,
"start_line": 69
} |
Prims.Tot | val step (p: protocol 'a {more_msgs p}) (x: next_msg_t p) : protocol 'a | [
{
"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 step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x | val step (p: protocol 'a {more_msgs p}) (x: next_msg_t p) : protocol 'a
let step (p: protocol 'a {more_msgs p}) (x: next_msg_t p) : protocol 'a = | false | null | false | Msg?.k (hnf p) x | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.b2t",
"Steel.Channel.Protocol.more_msgs",
"Steel.Channel.Protocol.next_msg_t",
"Steel.Channel.Protocol.__proj__Msg__item__k",
"Steel.Channel.Protocol.hnf"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p) | false | false | Steel.Channel.Protocol.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 step (p: protocol 'a {more_msgs p}) (x: next_msg_t p) : protocol 'a | [] | Steel.Channel.Protocol.step | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
p: Steel.Channel.Protocol.protocol 'a {Steel.Channel.Protocol.more_msgs p} ->
x: Steel.Channel.Protocol.next_msg_t p
-> Steel.Channel.Protocol.protocol 'a | {
"end_col": 87,
"end_line": 89,
"start_col": 71,
"start_line": 89
} |
Prims.Tot | val bind (#a #b: _) (p: protocol a) (q: (a -> protocol b)) : protocol b | [
{
"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 rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q) | val bind (#a #b: _) (p: protocol a) (q: (a -> protocol b)) : protocol b
let rec bind #a #b (p: protocol a) (q: (a -> protocol b)) : protocol b = | false | null | false | match p with
| Return v -> q v
| Msg tag c #a' k ->
let k: c -> protocol b = fun x -> bind (k x) q in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Steel.Channel.Protocol.tag",
"Steel.Channel.Protocol.prot",
"Steel.Channel.Protocol.Msg",
"Steel.Channel.Protocol.bind",
"Prims.bool",
"Steel.Channel.Protocol.DoWhile"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b)) | false | false | Steel.Channel.Protocol.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val bind (#a #b: _) (p: protocol a) (q: (a -> protocol b)) : protocol b | [
"recursion"
] | Steel.Channel.Protocol.bind | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Channel.Protocol.protocol a -> q: (_: a -> Steel.Channel.Protocol.protocol b)
-> Steel.Channel.Protocol.protocol b | {
"end_col": 41,
"end_line": 62,
"start_col": 4,
"start_line": 55
} |
Prims.Tot | val hnf (p: protocol 'a) : (q: protocol 'a {(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) | [
{
"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 rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p | val hnf (p: protocol 'a) : (q: protocol 'a {(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
let rec hnf (p: protocol 'a)
: (q: protocol 'a {(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) = | false | null | false | match p with
| DoWhile p k ->
let^ b = hnf p in
if b then DoWhile p k else k
| _ -> p | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Steel.Channel.Protocol.prot",
"Prims.bool",
"Steel.Channel.Protocol.op_let_Hat",
"Steel.Channel.Protocol.hnf",
"Steel.Channel.Protocol.DoWhile",
"Prims.l_and",
"Prims.l_or",
"Prims.b2t",
"Steel.Channel.Protocol.uu___is_Return",
"Steel.Channel.Protocol.uu___is_Msg",
"Prims.l_imp",
"Prims.l_not",
"Steel.Channel.Protocol.uu___is_DoWhile",
"Prims.eq2"
] | [] | (*
Copyright 2020 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Steel.Channel.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a) | false | false | Steel.Channel.Protocol.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 hnf (p: protocol 'a) : (q: protocol 'a {(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))}) | [
"recursion"
] | Steel.Channel.Protocol.hnf | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Channel.Protocol.protocol 'a
-> q: Steel.Channel.Protocol.protocol 'a {(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> p == q)} | {
"end_col": 12,
"end_line": 84,
"start_col": 4,
"start_line": 82
} |
Prims.Tot | val next (#p: protocol unit) : P.relation (partial_trace_of p) | [
{
"abbrev": true,
"full_module": "FStar.ReflexiveTransitiveClosure",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"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 next (#p:protocol unit) : P.relation (partial_trace_of p) =
fun (t0 t1: partial_trace_of p) ->
more_msgs t0.to /\
(exists (msg:next_msg_t t0.to).
t1.to == step t0.to msg /\
t1.tr == extend t0.tr msg) | val next (#p: protocol unit) : P.relation (partial_trace_of p)
let next (#p: protocol unit) : P.relation (partial_trace_of p) = | false | null | false | fun (t0: partial_trace_of p) (t1: partial_trace_of p) ->
more_msgs t0.to /\
(exists (msg: next_msg_t t0.to). t1.to == step t0.to msg /\ t1.tr == extend t0.tr msg) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"Steel.Channel.Protocol.partial_trace_of",
"Prims.l_and",
"Prims.b2t",
"Steel.Channel.Protocol.more_msgs",
"Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__to",
"Prims.l_Exists",
"Steel.Channel.Protocol.next_msg_t",
"Prims.eq2",
"Steel.Channel.Protocol.step",
"Steel.Channel.Protocol.trace",
"Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__tr",
"Steel.Channel.Protocol.extend",
"FStar.Preorder.relation"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m)
let rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x))
(decreases t)
= match t with
| Message _ x _ (Waiting _) -> (| from , x, () |)
| Message _ _ _ tail -> last_step_of tail
noeq
type partial_trace_of (p:protocol unit) = {
to:protocol unit;
tr:trace p to
}
module P = FStar.Preorder
module R = FStar.ReflexiveTransitiveClosure | false | false | Steel.Channel.Protocol.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 next (#p: protocol unit) : P.relation (partial_trace_of p) | [] | Steel.Channel.Protocol.next | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | FStar.Preorder.relation (Steel.Channel.Protocol.partial_trace_of p) | {
"end_col": 32,
"end_line": 136,
"start_col": 2,
"start_line": 132
} |
Prims.Tot | val extended_to (#p: protocol unit) : P.preorder (partial_trace_of p) | [
{
"abbrev": true,
"full_module": "FStar.ReflexiveTransitiveClosure",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"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 extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) =
R.closure (next #p) | val extended_to (#p: protocol unit) : P.preorder (partial_trace_of p)
let extended_to (#p: protocol unit) : P.preorder (partial_trace_of p) = | false | null | false | R.closure (next #p) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"FStar.ReflexiveTransitiveClosure.closure",
"Steel.Channel.Protocol.partial_trace_of",
"Steel.Channel.Protocol.next",
"FStar.Preorder.preorder"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m)
let rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x))
(decreases t)
= match t with
| Message _ x _ (Waiting _) -> (| from , x, () |)
| Message _ _ _ tail -> last_step_of tail
noeq
type partial_trace_of (p:protocol unit) = {
to:protocol unit;
tr:trace p to
}
module P = FStar.Preorder
module R = FStar.ReflexiveTransitiveClosure
let next (#p:protocol unit) : P.relation (partial_trace_of p) =
fun (t0 t1: partial_trace_of p) ->
more_msgs t0.to /\
(exists (msg:next_msg_t t0.to).
t1.to == step t0.to msg /\
t1.tr == extend t0.tr msg) | false | false | Steel.Channel.Protocol.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 extended_to (#p: protocol unit) : P.preorder (partial_trace_of p) | [] | Steel.Channel.Protocol.extended_to | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | FStar.Preorder.preorder (Steel.Channel.Protocol.partial_trace_of p) | {
"end_col": 21,
"end_line": 139,
"start_col": 2,
"start_line": 139
} |
Prims.Tot | val dual (#a: _) (p: protocol a) : q: protocol a {Msg? p ==> Msg? q} | [
{
"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 rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k) | val dual (#a: _) (p: protocol a) : q: protocol a {Msg? p ==> Msg? q}
let rec dual #a (p: protocol a) : q: protocol a {Msg? p ==> Msg? q} = | false | null | false | match p with
| Return _ -> p
| Msg tag b #a k ->
let k: b -> protocol a = fun (x: b) -> dual #a (k x) in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Steel.Channel.Protocol.tag",
"Steel.Channel.Protocol.prot",
"Steel.Channel.Protocol.Msg",
"Steel.Channel.Protocol.flip_tag",
"Steel.Channel.Protocol.dual",
"Prims.bool",
"Steel.Channel.Protocol.DoWhile",
"Prims.l_imp",
"Prims.b2t",
"Steel.Channel.Protocol.uu___is_Msg"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send | false | false | Steel.Channel.Protocol.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 dual (#a: _) (p: protocol a) : q: protocol a {Msg? p ==> Msg? q} | [
"recursion"
] | Steel.Channel.Protocol.dual | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Channel.Protocol.protocol a -> q: Steel.Channel.Protocol.protocol a {Msg? p ==> Msg? q} | {
"end_col": 50,
"end_line": 50,
"start_col": 2,
"start_line": 43
} |
Prims.GTot | val tag_of (p: protocol unit {more p}) : GTot tag | [
{
"abbrev": true,
"full_module": "FStar.ReflexiveTransitiveClosure",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"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 tag_of (p:protocol unit{more p}) : GTot tag = Msg?._0 (hnf p) | val tag_of (p: protocol unit {more p}) : GTot tag
let tag_of (p: protocol unit {more p}) : GTot tag = | false | null | false | Msg?._0 (hnf p) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"sometrivial"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"Prims.b2t",
"Steel.Channel.Protocol.more",
"Steel.Channel.Protocol.__proj__Msg__item___0",
"Steel.Channel.Protocol.hnf",
"Steel.Channel.Protocol.tag"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m)
let rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x))
(decreases t)
= match t with
| Message _ x _ (Waiting _) -> (| from , x, () |)
| Message _ _ _ tail -> last_step_of tail
noeq
type partial_trace_of (p:protocol unit) = {
to:protocol unit;
tr:trace p to
}
module P = FStar.Preorder
module R = FStar.ReflexiveTransitiveClosure
let next (#p:protocol unit) : P.relation (partial_trace_of p) =
fun (t0 t1: partial_trace_of p) ->
more_msgs t0.to /\
(exists (msg:next_msg_t t0.to).
t1.to == step t0.to msg /\
t1.tr == extend t0.tr msg)
let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) =
R.closure (next #p)
let extend_partial_trace (#p:protocol unit)
(x:partial_trace_of p)
(msg:next_msg_t x.to{more_msgs x.to})
: Tot (y:partial_trace_of p{x `extended_to` y})
= { to=_; tr=extend x.tr msg} | false | false | Steel.Channel.Protocol.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 tag_of (p: protocol unit {more p}) : GTot tag | [] | Steel.Channel.Protocol.tag_of | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | p: Steel.Channel.Protocol.protocol Prims.unit {Steel.Channel.Protocol.more p}
-> Prims.GTot Steel.Channel.Protocol.tag | {
"end_col": 65,
"end_line": 149,
"start_col": 50,
"start_line": 149
} |
Prims.Tot | val extend_partial_trace
(#p: protocol unit)
(x: partial_trace_of p)
(msg: next_msg_t x.to {more_msgs x.to})
: Tot (y: partial_trace_of p {x `extended_to` y}) | [
{
"abbrev": true,
"full_module": "FStar.ReflexiveTransitiveClosure",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Preorder",
"short_module": "P"
},
{
"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 extend_partial_trace (#p:protocol unit)
(x:partial_trace_of p)
(msg:next_msg_t x.to{more_msgs x.to})
: Tot (y:partial_trace_of p{x `extended_to` y})
= { to=_; tr=extend x.tr msg} | val extend_partial_trace
(#p: protocol unit)
(x: partial_trace_of p)
(msg: next_msg_t x.to {more_msgs x.to})
: Tot (y: partial_trace_of p {x `extended_to` y})
let extend_partial_trace
(#p: protocol unit)
(x: partial_trace_of p)
(msg: next_msg_t x.to {more_msgs x.to})
: Tot (y: partial_trace_of p {x `extended_to` y}) = | false | null | false | { to = _; tr = extend x.tr msg } | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total"
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"Steel.Channel.Protocol.partial_trace_of",
"Steel.Channel.Protocol.next_msg_t",
"Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__to",
"Prims.b2t",
"Steel.Channel.Protocol.more_msgs",
"Steel.Channel.Protocol.Mkpartial_trace_of",
"Steel.Channel.Protocol.step",
"Steel.Channel.Protocol.extend",
"Steel.Channel.Protocol.__proj__Mkpartial_trace_of__item__tr",
"Steel.Channel.Protocol.extended_to"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m)
let rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x))
(decreases t)
= match t with
| Message _ x _ (Waiting _) -> (| from , x, () |)
| Message _ _ _ tail -> last_step_of tail
noeq
type partial_trace_of (p:protocol unit) = {
to:protocol unit;
tr:trace p to
}
module P = FStar.Preorder
module R = FStar.ReflexiveTransitiveClosure
let next (#p:protocol unit) : P.relation (partial_trace_of p) =
fun (t0 t1: partial_trace_of p) ->
more_msgs t0.to /\
(exists (msg:next_msg_t t0.to).
t1.to == step t0.to msg /\
t1.tr == extend t0.tr msg)
let extended_to (#p:protocol unit) : P.preorder (partial_trace_of p) =
R.closure (next #p)
let extend_partial_trace (#p:protocol unit)
(x:partial_trace_of p)
(msg:next_msg_t x.to{more_msgs x.to}) | false | false | Steel.Channel.Protocol.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val extend_partial_trace
(#p: protocol unit)
(x: partial_trace_of p)
(msg: next_msg_t x.to {more_msgs x.to})
: Tot (y: partial_trace_of p {x `extended_to` y}) | [] | Steel.Channel.Protocol.extend_partial_trace | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
x: Steel.Channel.Protocol.partial_trace_of p ->
msg:
Steel.Channel.Protocol.next_msg_t (Mkpartial_trace_of?.to x)
{Steel.Channel.Protocol.more_msgs (Mkpartial_trace_of?.to x)}
-> y: Steel.Channel.Protocol.partial_trace_of p {Steel.Channel.Protocol.extended_to x y} | {
"end_col": 30,
"end_line": 145,
"start_col": 6,
"start_line": 145
} |
Prims.Tot | val last_step_of (#from #to: protocol unit) (t: trace from to {~(Waiting? t)})
: Tot (q: protocol unit & x: next_msg_t q & squash (more_msgs q /\ to == step q x))
(decreases t) | [
{
"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 rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x))
(decreases t)
= match t with
| Message _ x _ (Waiting _) -> (| from , x, () |)
| Message _ _ _ tail -> last_step_of tail | val last_step_of (#from #to: protocol unit) (t: trace from to {~(Waiting? t)})
: Tot (q: protocol unit & x: next_msg_t q & squash (more_msgs q /\ to == step q x))
(decreases t)
let rec last_step_of (#from #to: protocol unit) (t: trace from to {~(Waiting? t)})
: Tot (q: protocol unit & x: next_msg_t q & squash (more_msgs q /\ to == step q x))
(decreases t) = | false | null | false | match t with
| Message _ x _ (Waiting _) -> (| from, x, () |)
| Message _ _ _ tail -> last_step_of tail | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total",
""
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"Steel.Channel.Protocol.trace",
"Prims.l_not",
"Prims.b2t",
"Steel.Channel.Protocol.uu___is_Waiting",
"Steel.Channel.Protocol.more_msgs",
"Steel.Channel.Protocol.next_msg_t",
"FStar.Pervasives.Mkdtuple3",
"Prims.squash",
"Prims.l_and",
"Prims.eq2",
"Steel.Channel.Protocol.step",
"Steel.Channel.Protocol.last_step_of",
"FStar.Pervasives.dtuple3"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m)
let rec last_step_of (#from #to:protocol unit)
(t:trace from to { ~ (Waiting? t) })
: Tot (q:protocol unit &
x:next_msg_t q &
squash (more_msgs q /\to == step q x)) | false | false | Steel.Channel.Protocol.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 last_step_of (#from #to: protocol unit) (t: trace from to {~(Waiting? t)})
: Tot (q: protocol unit & x: next_msg_t q & squash (more_msgs q /\ to == step q x))
(decreases t) | [
"recursion"
] | Steel.Channel.Protocol.last_step_of | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | t: Steel.Channel.Protocol.trace from to {~(Waiting? t)}
-> Prims.Tot
(FStar.Pervasives.dtuple3 (Steel.Channel.Protocol.protocol Prims.unit)
(fun q -> Steel.Channel.Protocol.next_msg_t q)
(fun q x ->
Prims.squash (Steel.Channel.Protocol.more_msgs q /\
to == Steel.Channel.Protocol.step q x))) | {
"end_col": 46,
"end_line": 120,
"start_col": 5,
"start_line": 118
} |
Prims.Tot | val extend (#from #to: protocol unit) (t: trace from to {more_msgs to}) (m: next_msg_t to)
: Tot (trace from (step to m)) (decreases t) | [
{
"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 rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
= match t with
| Waiting _ ->
Message _ _ _ (Waiting (step to m))
| Message _from x _to tail ->
Message _ _ _ (extend tail m) | val extend (#from #to: protocol unit) (t: trace from to {more_msgs to}) (m: next_msg_t to)
: Tot (trace from (step to m)) (decreases t)
let rec extend (#from #to: protocol unit) (t: trace from to {more_msgs to}) (m: next_msg_t to)
: Tot (trace from (step to m)) (decreases t) = | false | null | false | match t with
| Waiting _ -> Message _ _ _ (Waiting (step to m))
| Message _from x _to tail -> Message _ _ _ (extend tail m) | {
"checked_file": "Steel.Channel.Protocol.fst.checked",
"dependencies": [
"prims.fst.checked",
"FStar.ReflexiveTransitiveClosure.fsti.checked",
"FStar.Preorder.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "Steel.Channel.Protocol.fst"
} | [
"total",
""
] | [
"Steel.Channel.Protocol.protocol",
"Prims.unit",
"Steel.Channel.Protocol.trace",
"Prims.b2t",
"Steel.Channel.Protocol.more_msgs",
"Steel.Channel.Protocol.next_msg_t",
"Steel.Channel.Protocol.Message",
"Steel.Channel.Protocol.step",
"Steel.Channel.Protocol.Waiting",
"Steel.Channel.Protocol.extend"
] | [] | (*
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.Protocol
type tag = | Send | Recv
// AF: Make it non erasable for now to implement duplex.PCM
//[@@erasable]
noeq
type prot : Type -> Type =
| Return : #a:Type -> v:a -> prot a
| Msg : tag -> a:Type -> #b:Type -> k:(a -> prot b) -> prot b
| DoWhile : prot bool -> #a:Type -> k:prot a -> prot a
let rec ok #a (p:prot a) =
match p with
| Return _ -> True
| Msg _ a k -> (forall x. ok (k x))
| DoWhile p k -> Msg? p /\ ok p /\ ok k
let protocol a = p:prot a { ok p }
let flip_tag = function
| Send -> Recv
| Recv -> Send
let rec dual #a (p:protocol a) : q:protocol a{Msg? p ==> Msg? q} =
match p with
| Return _ -> p
| Msg tag b #a k ->
let k : b -> protocol a =
fun (x:b) -> dual #a (k x)
in
Msg (flip_tag tag) b #a k
| DoWhile p #a k -> DoWhile (dual p) #a (dual k)
let rec bind #a #b (p:protocol a) (q:(a -> protocol b))
: protocol b
= match p with
| Return v -> q v
| Msg tag c #a' k ->
let k : c -> protocol b =
fun x -> bind (k x) q
in
Msg tag c k
| DoWhile w k -> DoWhile w (bind k q)
unfold
let (let^) = bind
let return (#a:Type) (x:a) : protocol a = Return x
let done = return ()
let send (t:Type) : protocol t = Msg Send t (fun x -> return x)
let recv (t:Type) : protocol t = Msg Recv t (fun x -> return x)
(* Some simple protocols *)
(* Send an int [x], recv a [y > x] *)
let xy : prot unit =
let^ x = send int in
let^ y = recv (y:int{y > x}) in
return ()
let rec hnf (p:protocol 'a)
: (q:protocol 'a{(Return? q \/ Msg? q) /\ (~(DoWhile? p) ==> (p == q))})
= match p with
| DoWhile p k -> let^ b = hnf p in if b then DoWhile p k else k
| _ -> p
let finished (p:protocol 'a) : GTot bool = Return? (hnf p)
let more_msgs (p:protocol 'a) : GTot bool = Msg? (hnf p)
let next_msg_t (p:protocol 'a) : Type = match hnf p with | Msg _ a _ -> a | Return #a _ -> a
let step (p:protocol 'a{more_msgs p}) (x:next_msg_t p) : protocol 'a = Msg?.k (hnf p) x
noeq
type trace : from:protocol unit -> to:protocol unit -> Type =
| Waiting : p:protocol unit -> trace p p
| Message : from:protocol unit{more_msgs from} ->
x:next_msg_t from ->
to:protocol unit ->
trace (step from x) to->
trace from to
let rec extend (#from #to:protocol unit)
(t:trace from to{more_msgs to})
(m:next_msg_t to) | false | false | Steel.Channel.Protocol.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val extend (#from #to: protocol unit) (t: trace from to {more_msgs to}) (m: next_msg_t to)
: Tot (trace from (step to m)) (decreases t) | [
"recursion"
] | Steel.Channel.Protocol.extend | {
"file_name": "lib/steel/Steel.Channel.Protocol.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
t: Steel.Channel.Protocol.trace from to {Steel.Channel.Protocol.more_msgs to} ->
m: Steel.Channel.Protocol.next_msg_t to
-> Prims.Tot (Steel.Channel.Protocol.trace from (Steel.Channel.Protocol.step to m)) | {
"end_col": 35,
"end_line": 109,
"start_col": 4,
"start_line": 105
} |
Prims.GTot | val no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' | val no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = | false | null | false | forall (x: bytes) (x': bytes).
{:pattern (no_lookahead_on_precond f x x')\/(no_lookahead_on_postcond f x x')}
(Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x' | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"Prims.l_Forall",
"LowParse.Bytes.bytes",
"Prims.l_imp",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.no_lookahead_on",
"LowParse.Spec.Base.no_lookahead_on_postcond",
"LowParse.Spec.Base.no_lookahead_on_precond"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t) | false | false | LowParse.Spec.Fuel.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 no_lookahead_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [] | LowParse.Spec.Fuel.no_lookahead_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0 | {
"end_col": 179,
"end_line": 16,
"start_col": 2,
"start_line": 16
} |
Prims.GTot | val injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2 | val injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = | false | null | false | forall (b1: bytes) (b2: bytes). {:pattern (injective_precond p b1 b2)\/(injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2 | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"Prims.l_Forall",
"LowParse.Bytes.bytes",
"Prims.l_imp",
"Prims.l_and",
"LowParse.Spec.Base.injective_precond",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.injective_postcond"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq | false | false | LowParse.Spec.Fuel.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 injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 | [] | LowParse.Spec.Fuel.injective_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> p: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0 | {
"end_col": 28,
"end_line": 9,
"start_col": 2,
"start_line": 7
} |
Prims.GTot | val is_total_constant_size_parser_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s)) | val is_total_constant_size_parser_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let is_total_constant_size_parser_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = | false | null | false | forall (s: bytes{Seq.length s < fuel}). {:pattern (parse f s)}
(Seq.length s < sz) == (None? (parse f s)) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"Prims.l_Forall",
"LowParse.Bytes.bytes",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.eq2",
"Prims.bool",
"FStar.Pervasives.Native.uu___is_None",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t) | false | false | LowParse.Spec.Fuel.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 is_total_constant_size_parser_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [] | LowParse.Spec.Fuel.is_total_constant_size_parser_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0 | {
"end_col": 44,
"end_line": 66,
"start_col": 2,
"start_line": 65
} |
Prims.GTot | val parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None | val parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = | false | null | false | forall (input: bytes{Seq.length input < fuel}). {:pattern (parse f input)} parse f input == None | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"Prims.l_Forall",
"LowParse.Bytes.bytes",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"FStar.Pervasives.Native.None"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s)) | false | false | LowParse.Spec.Fuel.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 parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [] | LowParse.Spec.Fuel.parser_always_fails_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0 | {
"end_col": 102,
"end_line": 69,
"start_col": 2,
"start_line": 69
} |
Prims.GTot | val parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f | val parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = | false | null | false | injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.bare_parser",
"Prims.l_and",
"LowParse.Spec.Base.injective",
"Prims.l_imp",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"LowParse.Spec.Base.parser_subkind_prop",
"FStar.Pervasives.Native.__proj__Some__item__v",
"LowParse.Spec.Base.parses_at_least",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"Prims.nat",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"LowParse.Spec.Base.parses_at_most",
"LowParse.Spec.Base.parser_kind_metadata_prop"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold | false | false | LowParse.Spec.Fuel.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 parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 | [] | LowParse.Spec.Fuel.parser_kind_prop' | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0 | {
"end_col": 31,
"end_line": 90,
"start_col": 2,
"start_line": 86
} |
Prims.GTot | val parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f | val parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 = | false | null | false | injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.bare_parser",
"Prims.l_and",
"LowParse.Spec.Fuel.injective_fuel",
"Prims.l_imp",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"LowParse.Spec.Fuel.parser_subkind_prop_fuel",
"FStar.Pervasives.Native.__proj__Some__item__v",
"LowParse.Spec.Fuel.parses_at_least_fuel",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"LowParse.Spec.Fuel.parses_at_most_fuel",
"LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f | false | false | LowParse.Spec.Fuel.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 parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 | [] | LowParse.Spec.Fuel.parser_kind_prop_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t
-> Prims.GTot Type0 | {
"end_col": 41,
"end_line": 82,
"start_col": 2,
"start_line": 78
} |
Prims.Tot | val close_by_fuel'
(#t: Type)
(f: (nat -> Tot (bare_parser t)))
(closure: (b: bytes -> GTot (n: nat{Seq.length b < n})))
: Tot (bare_parser t) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_by_fuel'
(#t: Type)
(f: (nat -> Tot (bare_parser t)))
(closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n })))
: Tot (bare_parser t)
= fun x -> f (closure x) x | val close_by_fuel'
(#t: Type)
(f: (nat -> Tot (bare_parser t)))
(closure: (b: bytes -> GTot (n: nat{Seq.length b < n})))
: Tot (bare_parser t)
let close_by_fuel'
(#t: Type)
(f: (nat -> Tot (bare_parser t)))
(closure: (b: bytes -> GTot (n: nat{Seq.length b < n})))
: Tot (bare_parser t) = | false | null | false | fun x -> f (closure x) x | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"total"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"LowParse.Bytes.bytes",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
= assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
let parser_kind_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f))
= injective_fuel_correct f;
begin match k.parser_kind_subkind with
| None -> ()
| Some k' -> parser_subkind_prop_fuel_correct k' f
end;
parses_at_least_fuel_correct k.parser_kind_low f;
begin match k.parser_kind_high with
| None -> ()
| Some max -> parses_at_most_fuel_correct max f
end;
parser_kind_metadata_prop_fuel_correct k f
let parser_kind_prop_fuel_complete'
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop' k f))
(ensures (parser_kind_prop_fuel fuel k f))
= ()
let parser_kind_prop_fuel_complete
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop k f))
(ensures (parser_kind_prop_fuel fuel k f))
= parser_kind_prop_equiv k f
let no_lookahead_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1))
let injective_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
injective_fuel fuel p2 <==> injective_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1));
Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1))
let parser_kind_prop_fuel_ext
(fuel: nat)
(#t: Type)
(k: parser_kind)
(f1 f2: bare_parser t)
: Lemma
(requires (forall (input: bytes { Seq.length input < fuel }) . parse f1 input == parse f2 input))
(ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2))
= no_lookahead_fuel_ext fuel f1 f2;
injective_fuel_ext fuel f1 f2
let close_by_fuel'
(#t: Type)
(f: (nat -> Tot (bare_parser t)))
(closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n }))) | false | false | LowParse.Spec.Fuel.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 close_by_fuel'
(#t: Type)
(f: (nat -> Tot (bare_parser t)))
(closure: (b: bytes -> GTot (n: nat{Seq.length b < n})))
: Tot (bare_parser t) | [] | LowParse.Spec.Fuel.close_by_fuel' | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
f: (_: Prims.nat -> LowParse.Spec.Base.bare_parser t) ->
closure: (b: LowParse.Bytes.bytes -> Prims.GTot (n: Prims.nat{FStar.Seq.Base.length b < n}))
-> LowParse.Spec.Base.bare_parser t | {
"end_col": 26,
"end_line": 206,
"start_col": 2,
"start_line": 206
} |
Prims.GTot | val consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
) | val consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0
let consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 = | false | null | false | forall (b: bytes{Seq.length b < fuel}). {:pattern (parse p b)}
Some? (parse p b) ==>
(let Some (_, len) = parse p b in
Seq.length b == len) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"Prims.l_Forall",
"LowParse.Bytes.bytes",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.l_imp",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"Prims.eq2",
"Prims.logical",
"FStar.Pervasives.Native.option"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t) | false | false | LowParse.Spec.Fuel.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 consumes_all_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 | [] | LowParse.Spec.Fuel.consumes_all_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> p: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0 | {
"end_col": 3,
"end_line": 26,
"start_col": 2,
"start_line": 23
} |
Prims.GTot | val parses_at_most_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
) | val parses_at_most_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let parses_at_most_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = | false | null | false | forall (s: bytes{Seq.length s < fuel}). {:pattern (parse f s)}
Some? (parse f s) ==>
(let _, consumed = Some?.v (parse f s) in
sz >= (consumed <: nat)) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"Prims.l_Forall",
"LowParse.Bytes.bytes",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.l_imp",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"Prims.op_GreaterThanOrEqual",
"Prims.logical",
"FStar.Pervasives.Native.__proj__Some__item__v"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t) | false | false | LowParse.Spec.Fuel.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 parses_at_most_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [] | LowParse.Spec.Fuel.parses_at_most_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0 | {
"end_col": 3,
"end_line": 57,
"start_col": 2,
"start_line": 53
} |
Prims.GTot | val parses_at_least_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
) | val parses_at_least_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0
let parses_at_least_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 = | false | null | false | forall (s: bytes{Seq.length s < fuel}). {:pattern (parse f s)}
Some? (parse f s) ==>
(let _, consumed = Some?.v (parse f s) in
sz <= (consumed <: nat)) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"Prims.l_Forall",
"LowParse.Bytes.bytes",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.l_imp",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"Prims.op_LessThanOrEqual",
"Prims.logical",
"FStar.Pervasives.Native.__proj__Some__item__v"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t) | false | false | LowParse.Spec.Fuel.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 parses_at_least_fuel (fuel sz: nat) (#t: Type) (f: bare_parser t) : GTot Type0 | [] | LowParse.Spec.Fuel.parses_at_least_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t -> Prims.GTot Type0 | {
"end_col": 3,
"end_line": 45,
"start_col": 2,
"start_line": 41
} |
Prims.GTot | val parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t)
: GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f | val parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t)
: GTot Type0
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t)
: GTot Type0 = | false | null | false | match k with
| ParserStrong -> no_lookahead_fuel fuel f
| ParserConsumesAll -> consumes_all_fuel fuel f | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.bare_parser",
"LowParse.Spec.Fuel.no_lookahead_fuel",
"LowParse.Spec.Fuel.consumes_all_fuel"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
) | false | false | LowParse.Spec.Fuel.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 parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t)
: GTot Type0 | [] | LowParse.Spec.Fuel.parser_subkind_prop_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> k: LowParse.Spec.Base.parser_subkind -> f: LowParse.Spec.Base.bare_parser t
-> Prims.GTot Type0 | {
"end_col": 28,
"end_line": 33,
"start_col": 2,
"start_line": 29
} |
Prims.GTot | val parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: GTot Type0 | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f | val parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: GTot Type0
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: GTot Type0 = | false | null | false | match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal ->
k.parser_kind_high == Some k.parser_kind_low ==>
is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"sometrivial"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.bare_parser",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_metadata",
"Prims.l_True",
"Prims.l_imp",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"FStar.Pervasives.Native.Some",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"LowParse.Spec.Fuel.is_total_constant_size_parser_fuel",
"LowParse.Spec.Fuel.parser_always_fails_fuel"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None | false | false | LowParse.Spec.Fuel.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 parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: GTot Type0 | [] | LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t
-> Prims.GTot Type0 | {
"end_col": 66,
"end_line": 75,
"start_col": 2,
"start_line": 72
} |
FStar.Pervasives.Lemma | val parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) | val parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f))
let parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) = | false | null | true | assert (forall x. Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"Prims._assert",
"Prims.l_Forall",
"FStar.Seq.Base.seq",
"LowParse.Bytes.byte",
"Prims.l_imp",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"LowParse.Spec.Fuel.parses_at_most_fuel",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Prims.unit",
"Prims.squash",
"LowParse.Spec.Base.parses_at_most",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f)) | false | false | LowParse.Spec.Fuel.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 parses_at_most_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parses_at_most_fuel fuel sz f)) (ensures (parses_at_most sz f)) | [] | LowParse.Spec.Fuel.parses_at_most_fuel_correct | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma
(requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parses_at_most_fuel fuel sz f)
(ensures LowParse.Spec.Base.parses_at_most sz f) | {
"end_col": 87,
"end_line": 115,
"start_col": 2,
"start_line": 115
} |
FStar.Pervasives.Lemma | val parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
= assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f) | val parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
let parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f)) = | false | null | true | assert (forall x.
let p = (parse f x) in
parser_kind_metadata_prop_fuel (Seq.length x + 1) k f) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.bare_parser",
"Prims._assert",
"Prims.l_Forall",
"FStar.Seq.Base.seq",
"LowParse.Bytes.byte",
"LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"Prims.unit",
"Prims.nat",
"Prims.squash",
"LowParse.Spec.Base.parser_kind_metadata_prop",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f)) | false | false | LowParse.Spec.Fuel.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 parser_kind_metadata_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f)) | [] | LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel_correct | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma
(requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel fuel k f
) (ensures LowParse.Spec.Base.parser_kind_metadata_prop k f) | {
"end_col": 99,
"end_line": 130,
"start_col": 2,
"start_line": 130
} |
FStar.Pervasives.Lemma | val parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) | val parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
let parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f)) = | false | null | true | assert (forall x. Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"Prims._assert",
"Prims.l_Forall",
"FStar.Seq.Base.seq",
"LowParse.Bytes.byte",
"Prims.l_imp",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"LowParse.Spec.Fuel.parses_at_least_fuel",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Prims.unit",
"Prims.squash",
"LowParse.Spec.Base.parses_at_least",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f)) | false | false | LowParse.Spec.Fuel.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 parses_at_least_fuel_correct (sz: nat) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f)) | [] | LowParse.Spec.Fuel.parses_at_least_fuel_correct | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | sz: Prims.nat -> f: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma
(requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parses_at_least_fuel fuel sz f)
(ensures LowParse.Spec.Base.parses_at_least sz f) | {
"end_col": 88,
"end_line": 106,
"start_col": 2,
"start_line": 106
} |
Prims.Tot | val close_by_fuel
(#k: parser_kind)
(#t: Type)
(f: (nat -> Tot (parser k t)))
(closure: (b: bytes -> Tot (n: nat{Seq.length b < n})))
(f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b)))
: Tot (parser k t) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_by_fuel
(#k: parser_kind)
(#t: Type)
(f: (nat -> Tot (parser k t)))
(closure: ((b: bytes) -> Tot (n: nat { Seq.length b < n })))
(f_ext: (
(fuel: nat) ->
(b: bytes { Seq.length b < fuel }) ->
Lemma
(f fuel b == f (closure b) b)
))
: Tot (parser k t)
= close_by_fuel_correct k f closure f_ext (fun fuel -> parser_kind_prop_equiv k (f fuel));
close_by_fuel' f closure | val close_by_fuel
(#k: parser_kind)
(#t: Type)
(f: (nat -> Tot (parser k t)))
(closure: (b: bytes -> Tot (n: nat{Seq.length b < n})))
(f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b)))
: Tot (parser k t)
let close_by_fuel
(#k: parser_kind)
(#t: Type)
(f: (nat -> Tot (parser k t)))
(closure: (b: bytes -> Tot (n: nat{Seq.length b < n})))
(f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b)))
: Tot (parser k t) = | false | null | false | close_by_fuel_correct k f closure f_ext (fun fuel -> parser_kind_prop_equiv k (f fuel));
close_by_fuel' f closure | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"total"
] | [
"LowParse.Spec.Base.parser_kind",
"Prims.nat",
"LowParse.Spec.Base.parser",
"LowParse.Bytes.bytes",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowParse.Spec.Fuel.close_by_fuel'",
"LowParse.Spec.Fuel.close_by_fuel_correct",
"LowParse.Spec.Base.parser_kind_prop_equiv"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
= assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
let parser_kind_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f))
= injective_fuel_correct f;
begin match k.parser_kind_subkind with
| None -> ()
| Some k' -> parser_subkind_prop_fuel_correct k' f
end;
parses_at_least_fuel_correct k.parser_kind_low f;
begin match k.parser_kind_high with
| None -> ()
| Some max -> parses_at_most_fuel_correct max f
end;
parser_kind_metadata_prop_fuel_correct k f
let parser_kind_prop_fuel_complete'
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop' k f))
(ensures (parser_kind_prop_fuel fuel k f))
= ()
let parser_kind_prop_fuel_complete
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop k f))
(ensures (parser_kind_prop_fuel fuel k f))
= parser_kind_prop_equiv k f
let no_lookahead_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1))
let injective_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
injective_fuel fuel p2 <==> injective_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1));
Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1))
let parser_kind_prop_fuel_ext
(fuel: nat)
(#t: Type)
(k: parser_kind)
(f1 f2: bare_parser t)
: Lemma
(requires (forall (input: bytes { Seq.length input < fuel }) . parse f1 input == parse f2 input))
(ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2))
= no_lookahead_fuel_ext fuel f1 f2;
injective_fuel_ext fuel f1 f2
let close_by_fuel'
(#t: Type)
(f: (nat -> Tot (bare_parser t)))
(closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n })))
: Tot (bare_parser t)
= fun x -> f (closure x) x
let close_by_fuel_correct
(#t: Type)
(k: parser_kind)
(f: (nat -> Tot (bare_parser t)))
(closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n })))
(f_ext: (
(fuel: nat) ->
(b: bytes { Seq.length b < fuel }) ->
Lemma
(f fuel b == f (closure b) b)
))
(f_prop: (
(fuel: nat) ->
Lemma
(parser_kind_prop_fuel fuel k (f fuel))
))
: Lemma
(parser_kind_prop k (close_by_fuel' f closure))
= let prf
(fuel: nat)
: Lemma
(parser_kind_prop_fuel fuel k (close_by_fuel' f closure))
= f_prop fuel;
let g
(b: bytes { Seq.length b < fuel })
: Lemma
(parse (close_by_fuel' f closure) b == parse (f fuel) b)
= f_ext fuel b
in
Classical.forall_intro g;
parser_kind_prop_fuel_ext fuel k (close_by_fuel' f closure) (f fuel)
in
Classical.forall_intro prf;
parser_kind_prop_fuel_correct k (close_by_fuel' f closure);
parser_kind_prop_equiv k (close_by_fuel' f closure)
let close_by_fuel
(#k: parser_kind)
(#t: Type)
(f: (nat -> Tot (parser k t)))
(closure: ((b: bytes) -> Tot (n: nat { Seq.length b < n })))
(f_ext: (
(fuel: nat) ->
(b: bytes { Seq.length b < fuel }) ->
Lemma
(f fuel b == f (closure b) b)
)) | false | false | LowParse.Spec.Fuel.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 close_by_fuel
(#k: parser_kind)
(#t: Type)
(f: (nat -> Tot (parser k t)))
(closure: (b: bytes -> Tot (n: nat{Seq.length b < n})))
(f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b)))
: Tot (parser k t) | [] | LowParse.Spec.Fuel.close_by_fuel | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
f: (_: Prims.nat -> LowParse.Spec.Base.parser k t) ->
closure: (b: LowParse.Bytes.bytes -> n: Prims.nat{FStar.Seq.Base.length b < n}) ->
f_ext:
(fuel: Prims.nat -> b: LowParse.Bytes.bytes{FStar.Seq.Base.length b < fuel}
-> FStar.Pervasives.Lemma (ensures f fuel b == f (closure b) b))
-> LowParse.Spec.Base.parser k t | {
"end_col": 26,
"end_line": 257,
"start_col": 2,
"start_line": 256
} |
FStar.Pervasives.Lemma | val parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) | val parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
let parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f)) = | false | null | true | assert (forall x y.
no_lookahead_on_precond f x y ==>
parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x. Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.bare_parser",
"Prims._assert",
"Prims.l_Forall",
"FStar.Seq.Base.seq",
"LowParse.Bytes.byte",
"Prims.l_imp",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"LowParse.Spec.Fuel.parser_subkind_prop_fuel",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Prims.unit",
"LowParse.Spec.Base.no_lookahead_on_precond",
"Prims.nat",
"Prims.squash",
"LowParse.Spec.Base.parser_subkind_prop",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f)) | false | false | LowParse.Spec.Fuel.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 parser_subkind_prop_fuel_correct (k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f)) | [] | LowParse.Spec.Fuel.parser_subkind_prop_fuel_correct | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | k: LowParse.Spec.Base.parser_subkind -> f: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma
(requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parser_subkind_prop_fuel fuel k f)
(ensures LowParse.Spec.Base.parser_subkind_prop k f) | {
"end_col": 91,
"end_line": 123,
"start_col": 2,
"start_line": 122
} |
FStar.Pervasives.Lemma | val parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_kind_prop_fuel_complete
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop k f))
(ensures (parser_kind_prop_fuel fuel k f))
= parser_kind_prop_equiv k f | val parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f))
let parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) = | false | null | true | parser_kind_prop_equiv k f | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.bare_parser",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"Prims.unit",
"LowParse.Spec.Base.parser_kind_prop",
"Prims.squash",
"LowParse.Spec.Fuel.parser_kind_prop_fuel",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
= assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
let parser_kind_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f))
= injective_fuel_correct f;
begin match k.parser_kind_subkind with
| None -> ()
| Some k' -> parser_subkind_prop_fuel_correct k' f
end;
parses_at_least_fuel_correct k.parser_kind_low f;
begin match k.parser_kind_high with
| None -> ()
| Some max -> parses_at_most_fuel_correct max f
end;
parser_kind_metadata_prop_fuel_correct k f
let parser_kind_prop_fuel_complete'
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop' k f))
(ensures (parser_kind_prop_fuel fuel k f))
= ()
let parser_kind_prop_fuel_complete
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop k f)) | false | false | LowParse.Spec.Fuel.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 parser_kind_prop_fuel_complete (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (parser_kind_prop k f)) (ensures (parser_kind_prop_fuel fuel k f)) | [] | LowParse.Spec.Fuel.parser_kind_prop_fuel_complete | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma (requires LowParse.Spec.Base.parser_kind_prop k f)
(ensures LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k f) | {
"end_col": 28,
"end_line": 161,
"start_col": 2,
"start_line": 161
} |
FStar.Pervasives.Lemma | val no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t)
: Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b))
(ensures (no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let no_lookahead_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1)) | val no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t)
: Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b))
(ensures (no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1))
let no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t)
: Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b))
(ensures (no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1)) = | false | null | true | Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1)) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"FStar.Classical.forall_intro_2",
"LowParse.Bytes.bytes",
"Prims.l_imp",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"Prims.l_iff",
"LowParse.Spec.Base.no_lookahead_on",
"FStar.Classical.move_requires",
"LowParse.Spec.Base.no_lookahead_on_ext",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims.l_Forall",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Fuel.no_lookahead_fuel"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
= assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
let parser_kind_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f))
= injective_fuel_correct f;
begin match k.parser_kind_subkind with
| None -> ()
| Some k' -> parser_subkind_prop_fuel_correct k' f
end;
parses_at_least_fuel_correct k.parser_kind_low f;
begin match k.parser_kind_high with
| None -> ()
| Some max -> parses_at_most_fuel_correct max f
end;
parser_kind_metadata_prop_fuel_correct k f
let parser_kind_prop_fuel_complete'
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop' k f))
(ensures (parser_kind_prop_fuel fuel k f))
= ()
let parser_kind_prop_fuel_complete
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop k f))
(ensures (parser_kind_prop_fuel fuel k f))
= parser_kind_prop_equiv k f
let no_lookahead_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1 | false | false | LowParse.Spec.Fuel.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 no_lookahead_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t)
: Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b))
(ensures (no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1)) | [] | LowParse.Spec.Fuel.no_lookahead_fuel_ext | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> p1: LowParse.Spec.Base.bare_parser t -> p2: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma
(requires
forall (b: LowParse.Bytes.bytes{FStar.Seq.Base.length b < fuel}).
LowParse.Spec.Base.parse p2 b == LowParse.Spec.Base.parse p1 b)
(ensures
LowParse.Spec.Fuel.no_lookahead_fuel fuel p2 <==>
LowParse.Spec.Fuel.no_lookahead_fuel fuel p1) | {
"end_col": 93,
"end_line": 174,
"start_col": 2,
"start_line": 174
} |
FStar.Pervasives.Lemma | val injective_fuel_correct (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. injective_fuel fuel f)) (ensures (injective f)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) | val injective_fuel_correct (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. injective_fuel fuel f)) (ensures (injective f))
let injective_fuel_correct (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. injective_fuel fuel f)) (ensures (injective f)) = | false | null | true | assert (forall x y. injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"LowParse.Spec.Base.bare_parser",
"Prims._assert",
"Prims.l_Forall",
"FStar.Seq.Base.seq",
"LowParse.Bytes.byte",
"Prims.l_imp",
"LowParse.Spec.Base.injective_precond",
"LowParse.Spec.Fuel.injective_fuel",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"Prims.unit",
"Prims.nat",
"Prims.squash",
"LowParse.Spec.Base.injective",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f)) | false | false | LowParse.Spec.Fuel.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 injective_fuel_correct (#t: Type) (f: bare_parser t)
: Lemma (requires (forall fuel. injective_fuel fuel f)) (ensures (injective f)) | [] | LowParse.Spec.Fuel.injective_fuel_correct | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | f: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma
(requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.injective_fuel fuel f)
(ensures LowParse.Spec.Base.injective f) | {
"end_col": 102,
"end_line": 97,
"start_col": 2,
"start_line": 97
} |
FStar.Pervasives.Lemma | val parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_kind_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f))
= injective_fuel_correct f;
begin match k.parser_kind_subkind with
| None -> ()
| Some k' -> parser_subkind_prop_fuel_correct k' f
end;
parses_at_least_fuel_correct k.parser_kind_low f;
begin match k.parser_kind_high with
| None -> ()
| Some max -> parses_at_most_fuel_correct max f
end;
parser_kind_metadata_prop_fuel_correct k f | val parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f))
let parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f)) = | false | null | true | injective_fuel_correct f;
(match k.parser_kind_subkind with
| None -> ()
| Some k' -> parser_subkind_prop_fuel_correct k' f);
parses_at_least_fuel_correct k.parser_kind_low f;
(match k.parser_kind_high with
| None -> ()
| Some max -> parses_at_most_fuel_correct max f);
parser_kind_metadata_prop_fuel_correct k f | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.bare_parser",
"LowParse.Spec.Fuel.parser_kind_metadata_prop_fuel_correct",
"Prims.unit",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_high",
"Prims.nat",
"LowParse.Spec.Fuel.parses_at_most_fuel_correct",
"LowParse.Spec.Fuel.parses_at_least_fuel_correct",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Fuel.parser_subkind_prop_fuel_correct",
"LowParse.Spec.Fuel.injective_fuel_correct",
"Prims.l_Forall",
"LowParse.Spec.Fuel.parser_kind_prop_fuel",
"Prims.squash",
"LowParse.Spec.Fuel.parser_kind_prop'",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
= assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
let parser_kind_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_prop_fuel fuel k f)) | false | false | LowParse.Spec.Fuel.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 parser_kind_prop_fuel_correct (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma (requires (forall fuel. parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f)) | [] | LowParse.Spec.Fuel.parser_kind_prop_fuel_correct | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | k: LowParse.Spec.Base.parser_kind -> f: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma
(requires forall (fuel: Prims.nat). LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k f)
(ensures LowParse.Spec.Fuel.parser_kind_prop' k f) | {
"end_col": 44,
"end_line": 147,
"start_col": 2,
"start_line": 137
} |
FStar.Pervasives.Lemma | val close_by_fuel_correct
(#t: Type)
(k: parser_kind)
(f: (nat -> Tot (bare_parser t)))
(closure: (b: bytes -> GTot (n: nat{Seq.length b < n})))
(f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b)))
(f_prop: (fuel: nat -> Lemma (parser_kind_prop_fuel fuel k (f fuel))))
: Lemma (parser_kind_prop k (close_by_fuel' f closure)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let close_by_fuel_correct
(#t: Type)
(k: parser_kind)
(f: (nat -> Tot (bare_parser t)))
(closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n })))
(f_ext: (
(fuel: nat) ->
(b: bytes { Seq.length b < fuel }) ->
Lemma
(f fuel b == f (closure b) b)
))
(f_prop: (
(fuel: nat) ->
Lemma
(parser_kind_prop_fuel fuel k (f fuel))
))
: Lemma
(parser_kind_prop k (close_by_fuel' f closure))
= let prf
(fuel: nat)
: Lemma
(parser_kind_prop_fuel fuel k (close_by_fuel' f closure))
= f_prop fuel;
let g
(b: bytes { Seq.length b < fuel })
: Lemma
(parse (close_by_fuel' f closure) b == parse (f fuel) b)
= f_ext fuel b
in
Classical.forall_intro g;
parser_kind_prop_fuel_ext fuel k (close_by_fuel' f closure) (f fuel)
in
Classical.forall_intro prf;
parser_kind_prop_fuel_correct k (close_by_fuel' f closure);
parser_kind_prop_equiv k (close_by_fuel' f closure) | val close_by_fuel_correct
(#t: Type)
(k: parser_kind)
(f: (nat -> Tot (bare_parser t)))
(closure: (b: bytes -> GTot (n: nat{Seq.length b < n})))
(f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b)))
(f_prop: (fuel: nat -> Lemma (parser_kind_prop_fuel fuel k (f fuel))))
: Lemma (parser_kind_prop k (close_by_fuel' f closure))
let close_by_fuel_correct
(#t: Type)
(k: parser_kind)
(f: (nat -> Tot (bare_parser t)))
(closure: (b: bytes -> GTot (n: nat{Seq.length b < n})))
(f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b)))
(f_prop: (fuel: nat -> Lemma (parser_kind_prop_fuel fuel k (f fuel))))
: Lemma (parser_kind_prop k (close_by_fuel' f closure)) = | false | null | true | let prf (fuel: nat) : Lemma (parser_kind_prop_fuel fuel k (close_by_fuel' f closure)) =
f_prop fuel;
let g (b: bytes{Seq.length b < fuel})
: Lemma (parse (close_by_fuel' f closure) b == parse (f fuel) b) =
f_ext fuel b
in
Classical.forall_intro g;
parser_kind_prop_fuel_ext fuel k (close_by_fuel' f closure) (f fuel)
in
Classical.forall_intro prf;
parser_kind_prop_fuel_correct k (close_by_fuel' f closure);
parser_kind_prop_equiv k (close_by_fuel' f closure) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"LowParse.Spec.Base.parser_kind",
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"LowParse.Bytes.bytes",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowParse.Spec.Fuel.parser_kind_prop_fuel",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"LowParse.Spec.Fuel.close_by_fuel'",
"LowParse.Spec.Fuel.parser_kind_prop_fuel_correct",
"FStar.Classical.forall_intro",
"LowParse.Spec.Fuel.parser_kind_prop_fuel_ext",
"LowParse.Spec.Base.parse",
"LowParse.Spec.Base.parser_kind_prop"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
= assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
let parser_kind_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f))
= injective_fuel_correct f;
begin match k.parser_kind_subkind with
| None -> ()
| Some k' -> parser_subkind_prop_fuel_correct k' f
end;
parses_at_least_fuel_correct k.parser_kind_low f;
begin match k.parser_kind_high with
| None -> ()
| Some max -> parses_at_most_fuel_correct max f
end;
parser_kind_metadata_prop_fuel_correct k f
let parser_kind_prop_fuel_complete'
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop' k f))
(ensures (parser_kind_prop_fuel fuel k f))
= ()
let parser_kind_prop_fuel_complete
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop k f))
(ensures (parser_kind_prop_fuel fuel k f))
= parser_kind_prop_equiv k f
let no_lookahead_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1))
let injective_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
injective_fuel fuel p2 <==> injective_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1));
Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1))
let parser_kind_prop_fuel_ext
(fuel: nat)
(#t: Type)
(k: parser_kind)
(f1 f2: bare_parser t)
: Lemma
(requires (forall (input: bytes { Seq.length input < fuel }) . parse f1 input == parse f2 input))
(ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2))
= no_lookahead_fuel_ext fuel f1 f2;
injective_fuel_ext fuel f1 f2
let close_by_fuel'
(#t: Type)
(f: (nat -> Tot (bare_parser t)))
(closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n })))
: Tot (bare_parser t)
= fun x -> f (closure x) x
let close_by_fuel_correct
(#t: Type)
(k: parser_kind)
(f: (nat -> Tot (bare_parser t)))
(closure: ((b: bytes) -> GTot (n: nat { Seq.length b < n })))
(f_ext: (
(fuel: nat) ->
(b: bytes { Seq.length b < fuel }) ->
Lemma
(f fuel b == f (closure b) b)
))
(f_prop: (
(fuel: nat) ->
Lemma
(parser_kind_prop_fuel fuel k (f fuel))
))
: Lemma | false | false | LowParse.Spec.Fuel.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 close_by_fuel_correct
(#t: Type)
(k: parser_kind)
(f: (nat -> Tot (bare_parser t)))
(closure: (b: bytes -> GTot (n: nat{Seq.length b < n})))
(f_ext: (fuel: nat -> b: bytes{Seq.length b < fuel} -> Lemma (f fuel b == f (closure b) b)))
(f_prop: (fuel: nat -> Lemma (parser_kind_prop_fuel fuel k (f fuel))))
: Lemma (parser_kind_prop k (close_by_fuel' f closure)) | [] | LowParse.Spec.Fuel.close_by_fuel_correct | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
k: LowParse.Spec.Base.parser_kind ->
f: (_: Prims.nat -> LowParse.Spec.Base.bare_parser t) ->
closure: (b: LowParse.Bytes.bytes -> Prims.GTot (n: Prims.nat{FStar.Seq.Base.length b < n})) ->
f_ext:
(fuel: Prims.nat -> b: LowParse.Bytes.bytes{FStar.Seq.Base.length b < fuel}
-> FStar.Pervasives.Lemma (ensures f fuel b == f (closure b) b)) ->
f_prop:
(fuel: Prims.nat
-> FStar.Pervasives.Lemma
(ensures LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k (f fuel)))
-> FStar.Pervasives.Lemma
(ensures LowParse.Spec.Base.parser_kind_prop k (LowParse.Spec.Fuel.close_by_fuel' f closure)) | {
"end_col": 53,
"end_line": 242,
"start_col": 1,
"start_line": 226
} |
FStar.Pervasives.Lemma | val injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t)
: Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b))
(ensures (injective_fuel fuel p2 <==> injective_fuel fuel p1)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let injective_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
injective_fuel fuel p2 <==> injective_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1));
Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1)) | val injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t)
: Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b))
(ensures (injective_fuel fuel p2 <==> injective_fuel fuel p1))
let injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t)
: Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b))
(ensures (injective_fuel fuel p2 <==> injective_fuel fuel p1)) = | false | null | true | Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1));
Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1)) | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.bare_parser",
"FStar.Classical.forall_intro_2",
"LowParse.Bytes.bytes",
"Prims.l_imp",
"Prims.l_and",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"Prims.l_iff",
"LowParse.Spec.Base.injective_postcond",
"FStar.Classical.move_requires",
"LowParse.Spec.Base.injective_postcond_ext",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowParse.Spec.Base.injective_precond",
"LowParse.Spec.Base.injective_precond_ext",
"Prims.l_Forall",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"LowParse.Spec.Fuel.injective_fuel"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
= assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
let parser_kind_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f))
= injective_fuel_correct f;
begin match k.parser_kind_subkind with
| None -> ()
| Some k' -> parser_subkind_prop_fuel_correct k' f
end;
parses_at_least_fuel_correct k.parser_kind_low f;
begin match k.parser_kind_high with
| None -> ()
| Some max -> parses_at_most_fuel_correct max f
end;
parser_kind_metadata_prop_fuel_correct k f
let parser_kind_prop_fuel_complete'
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop' k f))
(ensures (parser_kind_prop_fuel fuel k f))
= ()
let parser_kind_prop_fuel_complete
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop k f))
(ensures (parser_kind_prop_fuel fuel k f))
= parser_kind_prop_equiv k f
let no_lookahead_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1))
let injective_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
injective_fuel fuel p2 <==> injective_fuel fuel p1 | false | false | LowParse.Spec.Fuel.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 injective_fuel_ext (fuel: nat) (#t: Type) (p1 p2: bare_parser t)
: Lemma (requires (forall (b: bytes{Seq.length b < fuel}). parse p2 b == parse p1 b))
(ensures (injective_fuel fuel p2 <==> injective_fuel fuel p1)) | [] | LowParse.Spec.Fuel.injective_fuel_ext | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | fuel: Prims.nat -> p1: LowParse.Spec.Base.bare_parser t -> p2: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma
(requires
forall (b: LowParse.Bytes.bytes{FStar.Seq.Base.length b < fuel}).
LowParse.Spec.Base.parse p2 b == LowParse.Spec.Base.parse p1 b)
(ensures
LowParse.Spec.Fuel.injective_fuel fuel p2 <==> LowParse.Spec.Fuel.injective_fuel fuel p1) | {
"end_col": 96,
"end_line": 188,
"start_col": 2,
"start_line": 187
} |
FStar.Pervasives.Lemma | val parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t)
: Lemma
(requires (forall (input: bytes{Seq.length input < fuel}). parse f1 input == parse f2 input))
(ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2)) | [
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let parser_kind_prop_fuel_ext
(fuel: nat)
(#t: Type)
(k: parser_kind)
(f1 f2: bare_parser t)
: Lemma
(requires (forall (input: bytes { Seq.length input < fuel }) . parse f1 input == parse f2 input))
(ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2))
= no_lookahead_fuel_ext fuel f1 f2;
injective_fuel_ext fuel f1 f2 | val parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t)
: Lemma
(requires (forall (input: bytes{Seq.length input < fuel}). parse f1 input == parse f2 input))
(ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2))
let parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t)
: Lemma
(requires (forall (input: bytes{Seq.length input < fuel}). parse f1 input == parse f2 input))
(ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2)) = | false | null | true | no_lookahead_fuel_ext fuel f1 f2;
injective_fuel_ext fuel f1 f2 | {
"checked_file": "LowParse.Spec.Fuel.fst.checked",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": false,
"source_file": "LowParse.Spec.Fuel.fst"
} | [
"lemma"
] | [
"Prims.nat",
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.bare_parser",
"LowParse.Spec.Fuel.injective_fuel_ext",
"Prims.unit",
"LowParse.Spec.Fuel.no_lookahead_fuel_ext",
"Prims.l_Forall",
"LowParse.Bytes.bytes",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.Base.parse",
"Prims.squash",
"Prims.l_iff",
"LowParse.Spec.Fuel.parser_kind_prop_fuel",
"Prims.Nil",
"FStar.Pervasives.pattern"
] | [] | module LowParse.Spec.Fuel
include LowParse.Spec.Base
module Seq = FStar.Seq
let injective_fuel (fuel: nat) (#t: Type) (p: bare_parser t) : GTot Type0 =
forall (b1 b2: bytes) . {:pattern (injective_precond p b1 b2) \/ (injective_postcond p b1 b2)}
(injective_precond p b1 b2 /\ Seq.length b1 < fuel /\ Seq.length b2 < fuel) ==>
injective_postcond p b1 b2
let no_lookahead_fuel
(fuel: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (x x' : bytes) . {:pattern (no_lookahead_on_precond f x x') \/ (no_lookahead_on_postcond f x x')} (Seq.length x < fuel /\ Seq.length x' < fuel) ==> no_lookahead_on f x x'
let consumes_all_fuel
(fuel: nat)
(#t: Type)
(p: bare_parser t)
: GTot Type0
= forall (b: bytes { Seq.length b < fuel }) . {:pattern (parse p b)} Some? (parse p b) ==> (
let (Some (_, len)) = parse p b in
Seq.length b == len
)
let parser_subkind_prop_fuel (fuel: nat) (k: parser_subkind) (#t: Type) (f: bare_parser t) : GTot Type0 =
match k with
| ParserStrong ->
no_lookahead_fuel fuel f
| ParserConsumesAll ->
consumes_all_fuel fuel f
let parses_at_least_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz <= (consumed <: nat)
)
let parses_at_most_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s)}
Some? (parse f s) ==> (
let (_, consumed) = Some?.v (parse f s) in
sz >= (consumed <: nat)
)
let is_total_constant_size_parser_fuel
(fuel: nat)
(sz: nat)
(#t: Type)
(f: bare_parser t)
: GTot Type0
= forall (s: bytes { Seq.length s < fuel }) . {:pattern (parse f s) }
(Seq.length s < sz) == (None? (parse f s))
let parser_always_fails_fuel (fuel: nat) (#t: Type) (f: bare_parser t) : GTot Type0 =
forall (input: bytes { Seq.length input < fuel }) . {:pattern (parse f input)} parse f input == None
let parser_kind_metadata_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
match k.parser_kind_metadata with
| None -> True
| Some ParserKindMetadataTotal -> k.parser_kind_high == Some k.parser_kind_low ==> is_total_constant_size_parser_fuel fuel k.parser_kind_low f
| Some ParserKindMetadataFail -> parser_always_fails_fuel fuel f
let parser_kind_prop_fuel (fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective_fuel fuel f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop_fuel fuel (Some?.v k.parser_kind_subkind) f) /\
parses_at_least_fuel fuel k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most_fuel fuel (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop_fuel fuel k f
unfold
let parser_kind_prop' (#t: Type) (k: parser_kind) (f: bare_parser t) : GTot Type0 =
injective f /\
(Some? k.parser_kind_subkind ==> parser_subkind_prop (Some?.v k.parser_kind_subkind) f) /\
parses_at_least k.parser_kind_low f /\
(Some? k.parser_kind_high ==> (parses_at_most (Some?.v k.parser_kind_high) f)) /\
parser_kind_metadata_prop k f
let injective_fuel_correct
(#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . injective_fuel fuel f))
(ensures (injective f))
= assert (forall x y . injective_precond f x y ==> injective_fuel (Seq.length x + Seq.length y + 1) f)
let parses_at_least_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_least_fuel fuel sz f))
(ensures (parses_at_least sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_least_fuel (Seq.length x + 1) sz f)
let parses_at_most_fuel_correct
(sz: nat)
(#t: Type)
(f: bare_parser t)
: Lemma
(requires (forall fuel . parses_at_most_fuel fuel sz f))
(ensures (parses_at_most sz f))
= assert (forall x . Some? (parse f x) ==> parses_at_most_fuel (Seq.length x + 1) sz f)
let parser_subkind_prop_fuel_correct
(k: parser_subkind) (#t: Type) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_subkind_prop_fuel fuel k f))
(ensures (parser_subkind_prop k f))
= assert (forall x y . no_lookahead_on_precond f x y ==> parser_subkind_prop_fuel (Seq.length x + Seq.length y + 1) k f);
assert (forall x . Some? (parse f x) ==> parser_subkind_prop_fuel (Seq.length x + 1) k f)
let parser_kind_metadata_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_metadata_prop_fuel fuel k f))
(ensures (parser_kind_metadata_prop k f))
= assert (forall x . let p = (parse f x) in parser_kind_metadata_prop_fuel (Seq.length x + 1) k f)
let parser_kind_prop_fuel_correct
(#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (forall fuel . parser_kind_prop_fuel fuel k f))
(ensures (parser_kind_prop' k f))
= injective_fuel_correct f;
begin match k.parser_kind_subkind with
| None -> ()
| Some k' -> parser_subkind_prop_fuel_correct k' f
end;
parses_at_least_fuel_correct k.parser_kind_low f;
begin match k.parser_kind_high with
| None -> ()
| Some max -> parses_at_most_fuel_correct max f
end;
parser_kind_metadata_prop_fuel_correct k f
let parser_kind_prop_fuel_complete'
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop' k f))
(ensures (parser_kind_prop_fuel fuel k f))
= ()
let parser_kind_prop_fuel_complete
(fuel: nat) (#t: Type) (k: parser_kind) (f: bare_parser t)
: Lemma
(requires (parser_kind_prop k f))
(ensures (parser_kind_prop_fuel fuel k f))
= parser_kind_prop_equiv k f
let no_lookahead_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
no_lookahead_fuel fuel p2 <==> no_lookahead_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (no_lookahead_on_ext p1 p2 b1))
let injective_fuel_ext
(fuel: nat)
(#t: Type)
(p1 p2: bare_parser t)
: Lemma
(requires (
forall (b: bytes { Seq.length b < fuel }) . parse p2 b == parse p1 b
))
(ensures (
injective_fuel fuel p2 <==> injective_fuel fuel p1
))
= Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_precond_ext p1 p2 b1));
Classical.forall_intro_2 (fun b1 -> Classical.move_requires (injective_postcond_ext p1 p2 b1))
let parser_kind_prop_fuel_ext
(fuel: nat)
(#t: Type)
(k: parser_kind)
(f1 f2: bare_parser t)
: Lemma
(requires (forall (input: bytes { Seq.length input < fuel }) . parse f1 input == parse f2 input)) | false | false | LowParse.Spec.Fuel.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 parser_kind_prop_fuel_ext (fuel: nat) (#t: Type) (k: parser_kind) (f1 f2: bare_parser t)
: Lemma
(requires (forall (input: bytes{Seq.length input < fuel}). parse f1 input == parse f2 input))
(ensures (parser_kind_prop_fuel fuel k f1 <==> parser_kind_prop_fuel fuel k f2)) | [] | LowParse.Spec.Fuel.parser_kind_prop_fuel_ext | {
"file_name": "src/lowparse/LowParse.Spec.Fuel.fst",
"git_rev": "446a08ce38df905547cf20f28c43776b22b8087a",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} |
fuel: Prims.nat ->
k: LowParse.Spec.Base.parser_kind ->
f1: LowParse.Spec.Base.bare_parser t ->
f2: LowParse.Spec.Base.bare_parser t
-> FStar.Pervasives.Lemma
(requires
forall (input: LowParse.Bytes.bytes{FStar.Seq.Base.length input < fuel}).
LowParse.Spec.Base.parse f1 input == LowParse.Spec.Base.parse f2 input)
(ensures
LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k f1 <==>
LowParse.Spec.Fuel.parser_kind_prop_fuel fuel k f2) | {
"end_col": 31,
"end_line": 199,
"start_col": 2,
"start_line": 198
} |
Prims.GTot | val withlocalarray_soundness
(#g:stt_env)
(#t:st_term)
(#c:comp)
(d:st_typing g t c{T_WithLocalArray? d})
(soundness:soundness_t d)
: GTot (RT.tot_typing (elab_env g)
(elab_st_typing d)
(elab_comp c)) | [
{
"abbrev": true,
"full_module": "Pulse.Steel.Wrapper.Typing",
"short_module": "WT"
},
{
"abbrev": false,
"full_module": "Pulse.Soundness.Common",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Reflection.Util",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Reflection.Typing",
"short_module": "RT"
},
{
"abbrev": false,
"full_module": "Pulse.Soundness.Common",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Core",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Elaborate.Pure",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Typing",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Soundness",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Soundness",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | false | let withlocalarray_soundness #g #t #c d soundness =
let T_WithLocalArray _ init len body init_t c x init_typing len_typing init_t_typing c_typing body_typing = d in
let CT_ST _ st st_typing = c_typing in
let rg = elab_env g in
let ru = comp_u c in
let ra = elab_term init_t in
let rinit = elab_term init in
let rlen = elab_term len in
let rpre = elab_term (comp_pre c) in
let rret_t = elab_term (comp_res c) in
let rpost = elab_term (comp_post c) in
let rbody = elab_st_typing body_typing in
let a_typing = tot_typing_soundness init_t_typing in
let rinit_typing = tot_typing_soundness init_typing in
let rlen_typing = tot_typing_soundness len_typing in
let cres_typing, cpre_typing, cpost_typing =
Pulse.Soundness.Comp.stc_soundness st_typing in
let pre_typing = cpre_typing in
let ret_t_typing = cres_typing in
let post_typing = cpost_typing in
elab_push_binding g x (mk_array init_t);
let rbody_typing = soundness _ _ _ body_typing in
WT.with_localarray_typing
#rg
#ru
#ra
#rinit
#rlen
#rpre
#rret_t
#rpost
#rbody
x
a_typing
rinit_typing
rlen_typing
pre_typing
ret_t_typing
post_typing
rbody_typing | val withlocalarray_soundness
(#g:stt_env)
(#t:st_term)
(#c:comp)
(d:st_typing g t c{T_WithLocalArray? d})
(soundness:soundness_t d)
: GTot (RT.tot_typing (elab_env g)
(elab_st_typing d)
(elab_comp c))
let withlocalarray_soundness #g #t #c d soundness = | false | null | false | let
T_WithLocalArray
_
init
len
body
init_t
c
x
init_typing
len_typing
init_t_typing
c_typing
body_typing =
d
in
let CT_ST _ st st_typing = c_typing in
let rg = elab_env g in
let ru = comp_u c in
let ra = elab_term init_t in
let rinit = elab_term init in
let rlen = elab_term len in
let rpre = elab_term (comp_pre c) in
let rret_t = elab_term (comp_res c) in
let rpost = elab_term (comp_post c) in
let rbody = elab_st_typing body_typing in
let a_typing = tot_typing_soundness init_t_typing in
let rinit_typing = tot_typing_soundness init_typing in
let rlen_typing = tot_typing_soundness len_typing in
let cres_typing, cpre_typing, cpost_typing = Pulse.Soundness.Comp.stc_soundness st_typing in
let pre_typing = cpre_typing in
let ret_t_typing = cres_typing in
let post_typing = cpost_typing in
elab_push_binding g x (mk_array init_t);
let rbody_typing = soundness _ _ _ body_typing in
WT.with_localarray_typing #rg #ru #ra #rinit #rlen #rpre #rret_t #rpost #rbody x a_typing
rinit_typing rlen_typing pre_typing ret_t_typing post_typing rbody_typing | {
"checked_file": "Pulse.Soundness.WithLocalArray.fst.checked",
"dependencies": [
"Pulse.Typing.fst.checked",
"Pulse.Syntax.fst.checked",
"Pulse.Steel.Wrapper.Typing.fsti.checked",
"Pulse.Soundness.Comp.fsti.checked",
"Pulse.Soundness.Common.fst.checked",
"Pulse.Reflection.Util.fst.checked",
"Pulse.Elaborate.Core.fst.checked",
"Pulse.Elaborate.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Pulse.Soundness.WithLocalArray.fst"
} | [
"sometrivial"
] | [
"Pulse.Soundness.Common.stt_env",
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Base.comp",
"Pulse.Typing.st_typing",
"Prims.b2t",
"Pulse.Typing.uu___is_T_WithLocalArray",
"Pulse.Soundness.Common.soundness_t",
"Pulse.Typing.Env.env",
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.uu___is_C_ST",
"Pulse.Syntax.Base.var",
"Prims.l_and",
"FStar.Pervasives.Native.uu___is_None",
"Pulse.Syntax.Base.typ",
"Pulse.Typing.Env.lookup",
"Prims.l_not",
"FStar.Set.mem",
"Pulse.Syntax.Naming.freevars_st",
"Pulse.Typing.tot_typing",
"Pulse.Typing.tm_szt",
"Pulse.Typing.universe_of",
"Pulse.Syntax.Pure.u0",
"Pulse.Typing.comp_typing",
"Pulse.Syntax.Base.comp_u",
"Pulse.Typing.Env.push_binding",
"Pulse.Syntax.Base.ppname_default",
"Pulse.Typing.mk_array",
"Pulse.Syntax.Naming.open_st_term_nv",
"Pulse.Syntax.Base.v_as_nv",
"Pulse.Typing.comp_withlocal_array_body",
"Pulse.Syntax.Base.st_comp",
"Pulse.Typing.st_comp_typing",
"FStar.Reflection.Typing.tot_typing",
"Pulse.Typing.elab_env",
"Pulse.Elaborate.Pure.elab_term",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__res",
"FStar.Reflection.Typing.tm_type",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__u",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__pre",
"Pulse.Reflection.Util.vprop_tm",
"Pulse.Reflection.Util.mk_abs",
"FStar.Reflection.V2.Data.Q_Explicit",
"Pulse.Syntax.Base.__proj__Mkst_comp__item__post",
"Pulse.Soundness.Common.post1_type_bind",
"Pulse.Steel.Wrapper.Typing.with_localarray_typing",
"Pulse.Elaborate.Core.elab_st_typing",
"Pulse.Elaborate.Pure.elab_comp",
"Prims.unit",
"Pulse.Typing.elab_push_binding",
"FStar.Pervasives.Native.tuple3",
"Pulse.Soundness.Comp.stc_soundness",
"Pulse.Soundness.Common.tot_typing_soundness",
"Pulse.Syntax.Pure.tm_type",
"FStar.Reflection.Types.term",
"Pulse.Syntax.Base.comp_post",
"Pulse.Syntax.Base.comp_res",
"Pulse.Syntax.Base.comp_pre",
"Pulse.Syntax.Base.universe",
"FStar.Reflection.Types.env"
] | [] | module Pulse.Soundness.WithLocalArray
open Pulse.Syntax
open Pulse.Reflection.Util
open Pulse.Typing
open Pulse.Elaborate.Core
open Pulse.Elaborate
open Pulse.Soundness.Common
module WT = Pulse.Steel.Wrapper.Typing | false | false | Pulse.Soundness.WithLocalArray.fst | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 8,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 1,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 10,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val withlocalarray_soundness
(#g:stt_env)
(#t:st_term)
(#c:comp)
(d:st_typing g t c{T_WithLocalArray? d})
(soundness:soundness_t d)
: GTot (RT.tot_typing (elab_env g)
(elab_st_typing d)
(elab_comp c)) | [] | Pulse.Soundness.WithLocalArray.withlocalarray_soundness | {
"file_name": "lib/steel/pulse/Pulse.Soundness.WithLocalArray.fst",
"git_rev": "7fbb54e94dd4f48ff7cb867d3bae6889a635541e",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} |
d: Pulse.Typing.st_typing g t c {T_WithLocalArray? d} ->
soundness: Pulse.Soundness.Common.soundness_t d
-> Prims.GTot
(FStar.Reflection.Typing.tot_typing (Pulse.Typing.elab_env g)
(Pulse.Elaborate.Core.elab_st_typing d)
(Pulse.Elaborate.Pure.elab_comp c)) | {
"end_col": 16,
"end_line": 57,
"start_col": 51,
"start_line": 13
} |
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def | let eval_rounds_reveal = | false | null | true | opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.AES.AES_s.eval_rounds",
"Vale.AES.AES_s.eval_rounds_def"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) | false | false | Vale.AES.AES_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 eval_rounds_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.eval_rounds == Vale.AES.AES_s.eval_rounds_def) | [] | Vale.AES.AES_s.eval_rounds_reveal | {
"file_name": "vale/specs/crypto/Vale.AES.AES_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.AES_s.eval_rounds == Vale.AES.AES_s.eval_rounds_def) | {
"end_col": 96,
"end_line": 47,
"start_col": 37,
"start_line": 47
} |
|
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def | let expand_key_reveal = | false | null | true | opaque_revealer (`%expand_key) expand_key expand_key_def | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.AES.AES_common_s.algorithm",
"Vale.AES.AES_s.aes_key_LE",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Vale.AES.AES_common_s.nb",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.eq2",
"FStar.Seq.Base.length",
"Vale.AES.AES_s.expand_key",
"Vale.AES.AES_s.expand_key_def"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp)) | false | false | Vale.AES.AES_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 expand_key_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.expand_key == Vale.AES.AES_s.expand_key_def) | [] | Vale.AES.AES_s.expand_key_reveal | {
"file_name": "vale/specs/crypto/Vale.AES.AES_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.AES_s.expand_key == Vale.AES.AES_s.expand_key_def) | {
"end_col": 92,
"end_line": 81,
"start_col": 36,
"start_line": 81
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 eval_rounds = opaque_make eval_rounds_def | let eval_rounds = | false | null | false | opaque_make eval_rounds_def | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"total"
] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Vale.AES.AES_s.eval_rounds_def"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else | false | false | Vale.AES.AES_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 eval_rounds : _: Vale.Def.Types_s.quad32 ->
_: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
_: n: Prims.nat{n < FStar.Seq.Base.length _}
-> Vale.Def.Types_s.quad32 | [] | Vale.AES.AES_s.eval_rounds | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
_: Vale.Def.Types_s.quad32 ->
_: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
_: n: Prims.nat{n < FStar.Seq.Base.length _}
-> Vale.Def.Types_s.quad32 | {
"end_col": 64,
"end_line": 46,
"start_col": 37,
"start_line": 46
} |
|
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def | let eval_cipher_reveal = | false | null | true | opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.AES.AES_common_s.algorithm",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr",
"Prims.l_True",
"Vale.AES.AES_s.eval_cipher",
"Vale.AES.AES_s.eval_cipher_def"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state | false | false | Vale.AES.AES_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 eval_cipher_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma (ensures Vale.AES.AES_s.eval_cipher == Vale.AES.AES_s.eval_cipher_def) | [] | Vale.AES.AES_s.eval_cipher_reveal | {
"file_name": "vale/specs/crypto/Vale.AES.AES_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.AES_s.eval_cipher == Vale.AES.AES_s.eval_cipher_def) | {
"end_col": 96,
"end_line": 60,
"start_col": 37,
"start_line": 60
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s | let eval_round (state round_key: quad32) = | false | null | false | let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.quad32_xor",
"Vale.AES.AES_s.mix_columns_LE",
"Vale.AES.AES_s.shift_rows_LE",
"Vale.AES.AES_common_s.sub_bytes"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s} | false | true | Vale.AES.AES_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 eval_round : state: Vale.Def.Types_s.quad32 -> round_key: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32 | [] | Vale.AES.AES_s.eval_round | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | state: Vale.Def.Types_s.quad32 -> round_key: Vale.Def.Types_s.quad32 -> Vale.Def.Types_s.quad32 | {
"end_col": 3,
"end_line": 39,
"start_col": 41,
"start_line": 34
} |
|
Prims.Tot | val is_aes_key_LE (alg: algorithm) (s: seq nat32) : prop0 | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg | val is_aes_key_LE (alg: algorithm) (s: seq nat32) : prop0
let is_aes_key_LE (alg: algorithm) (s: seq nat32) : prop0 = | false | null | false | length s == nk alg | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Vale.AES.AES_common_s.nk",
"Vale.Def.Prop_s.prop0"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x)) | false | true | Vale.AES.AES_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_aes_key_LE (alg: algorithm) (s: seq nat32) : prop0 | [] | Vale.AES.AES_s.is_aes_key_LE | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Vale.AES.AES_common_s.algorithm -> s: FStar.Seq.Base.seq Vale.Def.Types_s.nat32
-> Vale.Def.Prop_s.prop0 | {
"end_col": 76,
"end_line": 31,
"start_col": 58,
"start_line": 31
} |
Prims.Pure | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 eval_cipher = opaque_make eval_cipher_def | let eval_cipher = | false | null | false | opaque_make eval_cipher_def | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.AES.AES_common_s.algorithm",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr",
"Prims.l_True",
"Vale.AES.AES_s.eval_cipher_def"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in | false | false | Vale.AES.AES_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 eval_cipher : alg: Vale.AES.AES_common_s.algorithm ->
input: Vale.Def.Types_s.quad32 ->
round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> Prims.Pure Vale.Def.Types_s.quad32 | [] | Vale.AES.AES_s.eval_cipher | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
alg: Vale.AES.AES_common_s.algorithm ->
input: Vale.Def.Types_s.quad32 ->
round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> Prims.Pure Vale.Def.Types_s.quad32 | {
"end_col": 64,
"end_line": 59,
"start_col": 37,
"start_line": 59
} |
|
Prims.Tot | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 expand_key = opaque_make expand_key_def | let expand_key = | false | null | false | opaque_make expand_key_def | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"total"
] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.AES.AES_common_s.algorithm",
"Vale.AES.AES_s.aes_key_LE",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Vale.AES.AES_common_s.nb",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.eq2",
"FStar.Seq.Base.length",
"Vale.AES.AES_s.expand_key_def"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in | false | false | Vale.AES.AES_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 expand_key : _: Vale.AES.AES_common_s.algorithm ->
_: Vale.AES.AES_s.aes_key_LE _ ->
_: size: Prims.nat{size <= Vale.AES.AES_common_s.nb * (Vale.AES.AES_common_s.nr _ + 1)}
-> ek_LE: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 {FStar.Seq.Base.length ek_LE == _} | [] | Vale.AES.AES_s.expand_key | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
_: Vale.AES.AES_common_s.algorithm ->
_: Vale.AES.AES_s.aes_key_LE _ ->
_: size: Prims.nat{size <= Vale.AES.AES_common_s.nb * (Vale.AES.AES_common_s.nr _ + 1)}
-> ek_LE: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 {FStar.Seq.Base.length ek_LE == _} | {
"end_col": 62,
"end_line": 80,
"start_col": 36,
"start_line": 80
} |
|
Prims.Pure | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 aes_encrypt_LE = opaque_make aes_encrypt_LE_def | let aes_encrypt_LE = | false | null | false | opaque_make aes_encrypt_LE_def | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [] | [
"Vale.Def.Opaque_s.opaque_make",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.is_aes_key_LE",
"Prims.l_True",
"Vale.AES.AES_s.aes_encrypt_LE_def"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
[@"opaque_to_smt"] let expand_key = opaque_make expand_key_def
irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def
let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds})
: (round_keys:seq quad32 {length round_keys == rounds}) =
if rounds = 0 then empty
else
let round_keys = key_schedule_to_round_keys (rounds - 1) w in
let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in
append round_keys (create 1 rk)
[@"opaque_to_smt"]
let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1)
=
key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1)))
let aes_encrypt_LE_def (alg:algorithm) (key:seq nat32) (input_LE:quad32) : Pure quad32
(requires is_aes_key_LE alg key)
(ensures fun _ -> True)
= | false | false | Vale.AES.AES_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 aes_encrypt_LE : alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 ->
input_LE: Vale.Def.Types_s.quad32
-> Prims.Pure Vale.Def.Types_s.quad32 | [] | Vale.AES.AES_s.aes_encrypt_LE | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 ->
input_LE: Vale.Def.Types_s.quad32
-> Prims.Pure Vale.Def.Types_s.quad32 | {
"end_col": 70,
"end_line": 103,
"start_col": 40,
"start_line": 103
} |
|
FStar.Pervasives.Lemma | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 aes_encrypt_LE_reveal = opaque_revealer (`%aes_encrypt_LE) aes_encrypt_LE aes_encrypt_LE_def | let aes_encrypt_LE_reveal = | false | null | true | opaque_revealer (`%aes_encrypt_LE) aes_encrypt_LE aes_encrypt_LE_def | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"lemma"
] | [
"Vale.Def.Opaque_s.opaque_revealer",
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.is_aes_key_LE",
"Prims.l_True",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.AES.AES_s.aes_encrypt_LE_def"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
[@"opaque_to_smt"] let expand_key = opaque_make expand_key_def
irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def
let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds})
: (round_keys:seq quad32 {length round_keys == rounds}) =
if rounds = 0 then empty
else
let round_keys = key_schedule_to_round_keys (rounds - 1) w in
let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in
append round_keys (create 1 rk)
[@"opaque_to_smt"]
let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1)
=
key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1)))
let aes_encrypt_LE_def (alg:algorithm) (key:seq nat32) (input_LE:quad32) : Pure quad32
(requires is_aes_key_LE alg key)
(ensures fun _ -> True)
=
eval_cipher_def alg input_LE (key_to_round_keys_LE alg key) | false | false | Vale.AES.AES_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 aes_encrypt_LE_reveal : _: Prims.unit
-> FStar.Pervasives.Lemma
(ensures Vale.AES.AES_s.aes_encrypt_LE == Vale.AES.AES_s.aes_encrypt_LE_def) | [] | Vale.AES.AES_s.aes_encrypt_LE_reveal | {
"file_name": "vale/specs/crypto/Vale.AES.AES_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.AES_s.aes_encrypt_LE == Vale.AES.AES_s.aes_encrypt_LE_def) | {
"end_col": 108,
"end_line": 104,
"start_col": 40,
"start_line": 104
} |
|
Prims.Pure | val aes_encrypt_LE_def (alg: algorithm) (key: seq nat32) (input_LE: quad32)
: Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True) | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 aes_encrypt_LE_def (alg:algorithm) (key:seq nat32) (input_LE:quad32) : Pure quad32
(requires is_aes_key_LE alg key)
(ensures fun _ -> True)
=
eval_cipher_def alg input_LE (key_to_round_keys_LE alg key) | val aes_encrypt_LE_def (alg: algorithm) (key: seq nat32) (input_LE: quad32)
: Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True)
let aes_encrypt_LE_def (alg: algorithm) (key: seq nat32) (input_LE: quad32)
: Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True) = | false | null | false | eval_cipher_def alg input_LE (key_to_round_keys_LE alg key) | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.eval_cipher_def",
"Vale.AES.AES_s.key_to_round_keys_LE",
"Vale.AES.AES_s.is_aes_key_LE",
"Prims.l_True"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
[@"opaque_to_smt"] let expand_key = opaque_make expand_key_def
irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def
let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds})
: (round_keys:seq quad32 {length round_keys == rounds}) =
if rounds = 0 then empty
else
let round_keys = key_schedule_to_round_keys (rounds - 1) w in
let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in
append round_keys (create 1 rk)
[@"opaque_to_smt"]
let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1)
=
key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1)))
let aes_encrypt_LE_def (alg:algorithm) (key:seq nat32) (input_LE:quad32) : Pure quad32
(requires is_aes_key_LE alg key)
(ensures fun _ -> True) | false | false | Vale.AES.AES_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 aes_encrypt_LE_def (alg: algorithm) (key: seq nat32) (input_LE: quad32)
: Pure quad32 (requires is_aes_key_LE alg key) (ensures fun _ -> True) | [] | Vale.AES.AES_s.aes_encrypt_LE_def | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
alg: Vale.AES.AES_common_s.algorithm ->
key: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 ->
input_LE: Vale.Def.Types_s.quad32
-> Prims.Pure Vale.Def.Types_s.quad32 | {
"end_col": 61,
"end_line": 102,
"start_col": 2,
"start_line": 102
} |
Prims.Tot | val eval_rounds_def (init: quad32) (round_keys: seq quad32) (n: nat{n < length round_keys}) : quad32 | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) | val eval_rounds_def (init: quad32) (round_keys: seq quad32) (n: nat{n < length round_keys}) : quad32
let rec eval_rounds_def (init: quad32) (round_keys: seq quad32) (n: nat{n < length round_keys})
: quad32 = | false | null | false | if n = 0 then init else eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n) | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"total"
] | [
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"FStar.Seq.Base.length",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Vale.AES.AES_s.eval_round",
"Vale.AES.AES_s.eval_rounds_def",
"Prims.op_Subtraction",
"FStar.Seq.Base.index"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s | false | false | Vale.AES.AES_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 eval_rounds_def (init: quad32) (round_keys: seq quad32) (n: nat{n < length round_keys}) : quad32 | [
"recursion"
] | Vale.AES.AES_s.eval_rounds_def | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
init: Vale.Def.Types_s.quad32 ->
round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32 ->
n: Prims.nat{n < FStar.Seq.Base.length round_keys}
-> Vale.Def.Types_s.quad32 | {
"end_col": 77,
"end_line": 45,
"start_col": 2,
"start_line": 42
} |
Prims.Pure | val key_to_round_keys_LE (alg: algorithm) (key: seq nat32)
: Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1) | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1)
=
key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1))) | val key_to_round_keys_LE (alg: algorithm) (key: seq nat32)
: Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1)
let key_to_round_keys_LE (alg: algorithm) (key: seq nat32)
: Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1) = | false | null | false | key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1))) | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [] | [
"Vale.AES.AES_common_s.algorithm",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Vale.AES.AES_s.key_schedule_to_round_keys",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr",
"Vale.AES.AES_s.expand_key",
"FStar.Mul.op_Star",
"Vale.AES.AES_common_s.nb",
"Vale.Def.Types_s.quad32",
"Vale.AES.AES_s.is_aes_key_LE",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
[@"opaque_to_smt"] let expand_key = opaque_make expand_key_def
irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def
let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds})
: (round_keys:seq quad32 {length round_keys == rounds}) =
if rounds = 0 then empty
else
let round_keys = key_schedule_to_round_keys (rounds - 1) w in
let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in
append round_keys (create 1 rk)
[@"opaque_to_smt"]
let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1) | false | false | Vale.AES.AES_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 key_to_round_keys_LE (alg: algorithm) (key: seq nat32)
: Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1) | [] | Vale.AES.AES_s.key_to_round_keys_LE | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | 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.quad32) | {
"end_col": 82,
"end_line": 96,
"start_col": 2,
"start_line": 96
} |
Prims.Tot | val key_schedule_to_round_keys (rounds: nat) (w: seq nat32 {length w >= 4 * rounds})
: (round_keys: seq quad32 {length round_keys == rounds}) | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds})
: (round_keys:seq quad32 {length round_keys == rounds}) =
if rounds = 0 then empty
else
let round_keys = key_schedule_to_round_keys (rounds - 1) w in
let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in
append round_keys (create 1 rk) | val key_schedule_to_round_keys (rounds: nat) (w: seq nat32 {length w >= 4 * rounds})
: (round_keys: seq quad32 {length round_keys == rounds})
let rec key_schedule_to_round_keys (rounds: nat) (w: seq nat32 {length w >= 4 * rounds})
: (round_keys: seq quad32 {length round_keys == rounds}) = | false | null | false | if rounds = 0
then empty
else
let round_keys = key_schedule_to_round_keys (rounds - 1) w in
let rk =
Mkfour (index w (4 * rounds - 4))
(index w (4 * rounds - 3))
(index w (4 * rounds - 2))
(index w (4 * rounds - 1))
in
append round_keys (create 1 rk) | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"total"
] | [
"Prims.nat",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.nat32",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.Seq.Base.length",
"FStar.Mul.op_Star",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.empty",
"Vale.Def.Types_s.quad32",
"Prims.bool",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words_s.Mkfour",
"FStar.Seq.Base.index",
"Prims.op_Subtraction",
"Prims.eq2",
"Vale.AES.AES_s.key_schedule_to_round_keys"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
[@"opaque_to_smt"] let expand_key = opaque_make expand_key_def
irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def
let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds}) | false | false | Vale.AES.AES_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 key_schedule_to_round_keys (rounds: nat) (w: seq nat32 {length w >= 4 * rounds})
: (round_keys: seq quad32 {length round_keys == rounds}) | [
"recursion"
] | Vale.AES.AES_s.key_schedule_to_round_keys | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
rounds: Prims.nat ->
w: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 {FStar.Seq.Base.length w >= 4 * rounds}
-> round_keys:
FStar.Seq.Base.seq Vale.Def.Types_s.quad32 {FStar.Seq.Base.length round_keys == rounds} | {
"end_col": 35,
"end_line": 89,
"start_col": 2,
"start_line": 85
} |
Prims.Tot | val key_to_round_keys (alg: algorithm) (key: aes_key alg)
: (round_keys: seq nat8 {length round_keys == 16 * (nr alg + 1)}) | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 key_to_round_keys (alg:algorithm) (key:aes_key alg)
: (round_keys:seq nat8 {length round_keys == 16 * (nr alg + 1)}) =
let key_LE = seq_nat8_to_seq_nat32_LE key in
le_seq_quad32_to_bytes (key_to_round_keys_LE alg key_LE) | val key_to_round_keys (alg: algorithm) (key: aes_key alg)
: (round_keys: seq nat8 {length round_keys == 16 * (nr alg + 1)})
let key_to_round_keys (alg: algorithm) (key: aes_key alg)
: (round_keys: seq nat8 {length round_keys == 16 * (nr alg + 1)}) = | false | null | false | let key_LE = seq_nat8_to_seq_nat32_LE key in
le_seq_quad32_to_bytes (key_to_round_keys_LE alg key_LE) | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.AES.AES_common_s.aes_key",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.AES.AES_s.key_to_round_keys_LE",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE",
"Vale.Def.Types_s.nat8",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"FStar.Mul.op_Star",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
[@"opaque_to_smt"] let expand_key = opaque_make expand_key_def
irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def
let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds})
: (round_keys:seq quad32 {length round_keys == rounds}) =
if rounds = 0 then empty
else
let round_keys = key_schedule_to_round_keys (rounds - 1) w in
let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in
append round_keys (create 1 rk)
[@"opaque_to_smt"]
let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1)
=
key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1)))
let aes_encrypt_LE_def (alg:algorithm) (key:seq nat32) (input_LE:quad32) : Pure quad32
(requires is_aes_key_LE alg key)
(ensures fun _ -> True)
=
eval_cipher_def alg input_LE (key_to_round_keys_LE alg key)
[@"opaque_to_smt"] let aes_encrypt_LE = opaque_make aes_encrypt_LE_def
irreducible let aes_encrypt_LE_reveal = opaque_revealer (`%aes_encrypt_LE) aes_encrypt_LE aes_encrypt_LE_def
#push-options "--z3rlimit 20" | false | false | Vale.AES.AES_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": 20,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | null | val key_to_round_keys (alg: algorithm) (key: aes_key alg)
: (round_keys: seq nat8 {length round_keys == 16 * (nr alg + 1)}) | [] | Vale.AES.AES_s.key_to_round_keys | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} | alg: Vale.AES.AES_common_s.algorithm -> key: Vale.AES.AES_common_s.aes_key alg
-> round_keys:
FStar.Seq.Base.seq Vale.Def.Types_s.nat8
{FStar.Seq.Base.length round_keys == 16 * (Vale.AES.AES_common_s.nr alg + 1)} | {
"end_col": 58,
"end_line": 110,
"start_col": 68,
"start_line": 108
} |
Prims.Pure | val eval_cipher_def (alg: algorithm) (input: quad32) (round_keys: seq quad32)
: Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state | val eval_cipher_def (alg: algorithm) (input: quad32) (round_keys: seq quad32)
: Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True)
let eval_cipher_def (alg: algorithm) (input: quad32) (round_keys: seq quad32)
: Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) = | false | null | false | let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.seq",
"Vale.Def.Types_s.quad32_xor",
"FStar.Seq.Base.index",
"Vale.AES.AES_common_s.nr",
"Vale.AES.AES_s.shift_rows_LE",
"Vale.AES.AES_common_s.sub_bytes",
"Vale.AES.AES_s.eval_rounds_def",
"Prims.op_Subtraction",
"Prims.eq2",
"Prims.int",
"FStar.Seq.Base.length",
"Prims.op_Addition",
"Prims.l_True"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1) | false | false | Vale.AES.AES_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 eval_cipher_def (alg: algorithm) (input: quad32) (round_keys: seq quad32)
: Pure quad32 (requires length round_keys == nr alg + 1) (ensures fun _ -> True) | [] | Vale.AES.AES_s.eval_cipher_def | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
alg: Vale.AES.AES_common_s.algorithm ->
input: Vale.Def.Types_s.quad32 ->
round_keys: FStar.Seq.Base.seq Vale.Def.Types_s.quad32
-> Prims.Pure Vale.Def.Types_s.quad32 | {
"end_col": 7,
"end_line": 58,
"start_col": 3,
"start_line": 52
} |
Prims.Tot | val aes_encrypt (alg: algorithm) (key: aes_key alg) (input: seq16 nat8) : seq16 nat8 | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 aes_encrypt (alg:algorithm) (key:aes_key alg) (input:seq16 nat8) : seq16 nat8 =
let key_LE = seq_nat8_to_seq_nat32_LE key in
let input_LE = le_bytes_to_quad32 input in
le_quad32_to_bytes (aes_encrypt_LE alg key_LE input_LE) | val aes_encrypt (alg: algorithm) (key: aes_key alg) (input: seq16 nat8) : seq16 nat8
let aes_encrypt (alg: algorithm) (key: aes_key alg) (input: seq16 nat8) : seq16 nat8 = | false | null | false | let key_LE = seq_nat8_to_seq_nat32_LE key in
let input_LE = le_bytes_to_quad32 input in
le_quad32_to_bytes (aes_encrypt_LE alg key_LE input_LE) | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.AES.AES_common_s.aes_key",
"Vale.Def.Words.Seq_s.seq16",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Types_s.quad32",
"Vale.Def.Types_s.le_bytes_to_quad32",
"FStar.Seq.Base.seq",
"Vale.Def.Words_s.nat32",
"Vale.Def.Words.Seq_s.seq_nat8_to_seq_nat32_LE"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp))
[@"opaque_to_smt"] let expand_key = opaque_make expand_key_def
irreducible let expand_key_reveal = opaque_revealer (`%expand_key) expand_key expand_key_def
let rec key_schedule_to_round_keys (rounds:nat) (w:seq nat32 {length w >= 4 * rounds})
: (round_keys:seq quad32 {length round_keys == rounds}) =
if rounds = 0 then empty
else
let round_keys = key_schedule_to_round_keys (rounds - 1) w in
let rk = Mkfour (index w (4 * rounds - 4)) (index w (4 * rounds - 3)) (index w (4 * rounds - 2)) (index w (4 * rounds - 1)) in
append round_keys (create 1 rk)
[@"opaque_to_smt"]
let key_to_round_keys_LE (alg:algorithm) (key:seq nat32) : Pure (seq quad32)
(requires is_aes_key_LE alg key)
(ensures fun round_keys -> length round_keys == nr alg + 1)
=
key_schedule_to_round_keys (nr alg + 1) (expand_key alg key (nb * (nr alg + 1)))
let aes_encrypt_LE_def (alg:algorithm) (key:seq nat32) (input_LE:quad32) : Pure quad32
(requires is_aes_key_LE alg key)
(ensures fun _ -> True)
=
eval_cipher_def alg input_LE (key_to_round_keys_LE alg key)
[@"opaque_to_smt"] let aes_encrypt_LE = opaque_make aes_encrypt_LE_def
irreducible let aes_encrypt_LE_reveal = opaque_revealer (`%aes_encrypt_LE) aes_encrypt_LE aes_encrypt_LE_def
#push-options "--z3rlimit 20"
let key_to_round_keys (alg:algorithm) (key:aes_key alg)
: (round_keys:seq nat8 {length round_keys == 16 * (nr alg + 1)}) =
let key_LE = seq_nat8_to_seq_nat32_LE key in
le_seq_quad32_to_bytes (key_to_round_keys_LE alg key_LE)
#pop-options | false | false | Vale.AES.AES_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 aes_encrypt (alg: algorithm) (key: aes_key alg) (input: seq16 nat8) : seq16 nat8 | [] | Vale.AES.AES_s.aes_encrypt | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
alg: Vale.AES.AES_common_s.algorithm ->
key: Vale.AES.AES_common_s.aes_key alg ->
input: Vale.Def.Words.Seq_s.seq16 Vale.Def.Types_s.nat8
-> Vale.Def.Words.Seq_s.seq16 Vale.Def.Types_s.nat8 | {
"end_col": 57,
"end_line": 116,
"start_col": 83,
"start_line": 113
} |
Prims.Tot | val expand_key_def (alg: algorithm) (key: aes_key_LE alg) (size: nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE: seq nat32 {length ek_LE == size}) | [
{
"abbrev": false,
"full_module": "Vale.AES.AES_common_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words.Four_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 expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE:seq nat32 {length ek_LE == size}) =
if size = 0 then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg then
append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0 then
nat32_xor (sub_word (rot_word_LE (index w (i-1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then
sub_word (index w (i - 1))
else
index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp)) | val expand_key_def (alg: algorithm) (key: aes_key_LE alg) (size: nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE: seq nat32 {length ek_LE == size})
let rec expand_key_def
(alg: algorithm)
(key: aes_key_LE alg)
(size: nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE: seq nat32 {length ek_LE == size}) = | false | null | false | if size = 0
then empty
else
let w = expand_key_def alg key (size - 1) in
let i = size - 1 in
if 0 <= i && i < nk alg
then append w (create 1 (index key i))
else
let temp =
if i % (nk alg) = 0
then nat32_xor (sub_word (rot_word_LE (index w (i - 1)))) (aes_rcon ((i / (nk alg)) - 1))
else if nk alg > 6 && i % (nk alg) = 4 then sub_word (index w (i - 1)) else index w (i - 1)
in
append w (create 1 (nat32_xor (index w (i - (nk alg))) temp)) | {
"checked_file": "Vale.AES.AES_s.fst.checked",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Words.Four_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.AES.AES_common_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.AES_s.fst"
} | [
"total"
] | [
"Vale.AES.AES_common_s.algorithm",
"Vale.AES.AES_s.aes_key_LE",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Vale.AES.AES_common_s.nb",
"Prims.op_Addition",
"Vale.AES.AES_common_s.nr",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.empty",
"Vale.Def.Types_s.nat32",
"Prims.bool",
"Prims.op_AmpAmp",
"Prims.op_LessThan",
"Vale.AES.AES_common_s.nk",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"FStar.Seq.Base.index",
"Vale.Def.Types_s.nat32_xor",
"Prims.op_Subtraction",
"Vale.Def.Words_s.nat32",
"Prims.op_Modulus",
"Vale.AES.AES_common_s.sub_word",
"Vale.AES.AES_s.rot_word_LE",
"Vale.AES.AES_common_s.aes_rcon",
"Prims.op_Division",
"Prims.op_GreaterThan",
"FStar.Seq.Base.seq",
"Prims.eq2",
"FStar.Seq.Base.length",
"Vale.AES.AES_s.expand_key_def"
] | [] | module Vale.AES.AES_s
// IMPORTANT: This specification is written assuming a little-endian mapping from bytes to quad32s
// This is explicit in key_schedule_to_round_keys when we construct the round_key rk,
// but it also applies implicitly to the input quad32
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open Vale.Def.Words_s
open Vale.Def.Words.Four_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open FStar.Seq
open FStar.Mul
include Vale.AES.AES_common_s
// operations assume that the quad32 and nat32 values are little-endian interpretations
// of 16-byte and 4-byte sequences
assume val mix_columns_LE (q:quad32) : quad32
assume val inv_mix_columns_LE (q:quad32) : quad32
assume val shift_rows_LE (q:quad32) : quad32
assume val inv_shift_rows_LE (q:quad32) : quad32
assume val rot_word_LE (w:nat32) : nat32
assume val commute_sub_bytes_shift_rows (q:quad32) : Lemma
(sub_bytes (shift_rows_LE q) == shift_rows_LE (sub_bytes q))
assume val commute_rot_word_sub_word (x:nat32) : Lemma
(rot_word_LE (sub_word x) == sub_word (rot_word_LE x))
let is_aes_key_LE (alg:algorithm) (s:seq nat32) : prop0 = length s == nk alg
type aes_key_LE (alg:algorithm) : eqtype = s:(seq nat32){is_aes_key_LE alg s}
let eval_round (state round_key:quad32) =
let s = sub_bytes state in
let s = shift_rows_LE s in
let s = mix_columns_LE s in
let s = quad32_xor s round_key in
s
let rec eval_rounds_def (init:quad32) (round_keys:seq quad32) (n:nat{n < length round_keys}) : quad32 =
if n = 0 then
init
else
eval_round (eval_rounds_def init round_keys (n - 1)) (index round_keys n)
[@"opaque_to_smt"] let eval_rounds = opaque_make eval_rounds_def
irreducible let eval_rounds_reveal = opaque_revealer (`%eval_rounds) eval_rounds eval_rounds_def
let eval_cipher_def (alg:algorithm) (input:quad32) (round_keys:seq quad32) : Pure quad32
(requires length round_keys == nr alg + 1)
(ensures fun _ -> True)
=
let state = quad32_xor input (index round_keys 0) in
let state = eval_rounds_def state round_keys (nr alg - 1) in
let state = sub_bytes state in
let state = shift_rows_LE state in
let state = quad32_xor state (index round_keys (nr alg)) in
state
[@"opaque_to_smt"] let eval_cipher = opaque_make eval_cipher_def
irreducible let eval_cipher_reveal = opaque_revealer (`%eval_cipher) eval_cipher eval_cipher_def
let rec expand_key_def (alg:algorithm) (key:aes_key_LE alg) (size:nat{size <= (nb * ((nr alg) + 1))}) | false | false | Vale.AES.AES_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 expand_key_def (alg: algorithm) (key: aes_key_LE alg) (size: nat{size <= (nb * ((nr alg) + 1))})
: (ek_LE: seq nat32 {length ek_LE == size}) | [
"recursion"
] | Vale.AES.AES_s.expand_key_def | {
"file_name": "vale/specs/crypto/Vale.AES.AES_s.fst",
"git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e",
"git_url": "https://github.com/hacl-star/hacl-star.git",
"project_name": "hacl-star"
} |
alg: Vale.AES.AES_common_s.algorithm ->
key: Vale.AES.AES_s.aes_key_LE alg ->
size: Prims.nat{size <= Vale.AES.AES_common_s.nb * (Vale.AES.AES_common_s.nr alg + 1)}
-> ek_LE: FStar.Seq.Base.seq Vale.Def.Types_s.nat32 {FStar.Seq.Base.length ek_LE == size} | {
"end_col": 67,
"end_line": 79,
"start_col": 2,
"start_line": 64
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.