file_name
stringlengths 5
52
| name
stringlengths 4
95
| original_source_type
stringlengths 0
23k
| source_type
stringlengths 9
23k
| source_definition
stringlengths 9
57.9k
| source
dict | source_range
dict | file_context
stringlengths 0
721k
| dependencies
dict | opens_and_abbrevs
listlengths 2
94
| vconfig
dict | interleaved
bool 1
class | verbose_type
stringlengths 1
7.42k
| effect
stringclasses 118
values | effect_flags
listlengths 0
2
| mutual_with
listlengths 0
11
| ideal_premises
listlengths 0
236
| proof_features
listlengths 0
1
| is_simple_lemma
bool 2
classes | is_div
bool 2
classes | is_proof
bool 2
classes | is_simply_typed
bool 2
classes | is_type
bool 2
classes | partial_definition
stringlengths 5
3.99k
| completed_definiton
stringlengths 1
1.63M
| isa_cross_project_example
bool 1
class |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.rounds | val rounds : a: Spec.Blake2.Definitions.alg -> Prims.int | let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 27,
"start_col": 0,
"start_line": 24
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Prims.int | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Prims.int"
]
| []
| false | false | false | true | false | let rounds (a: alg) =
| match a with
| Blake2S -> 10
| Blake2B -> 12 | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.size_hash_w | val size_hash_w:size_nat | val size_hash_w:size_nat | let size_hash_w : size_nat = 8 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 30,
"start_col": 22,
"start_line": 30
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
]
| []
| []
| []
| false | false | false | false | false | let size_hash_w:size_nat =
| 8 | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.size_block_w | val size_block_w:size_nat | val size_block_w:size_nat | let size_block_w : size_nat = 16 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 54,
"end_line": 31,
"start_col": 22,
"start_line": 31
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
]
| []
| []
| []
| false | false | false | false | false | let size_block_w:size_nat =
| 16 | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.size_word | val size_word (a: alg) : size_nat | val size_word (a: alg) : size_nat | let size_word (a:alg) : size_nat = numbytes (wt a) | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 72,
"end_line": 32,
"start_col": 22,
"start_line": 32
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.IntTypes.numbytes",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.size_nat"
]
| []
| false | false | false | true | false | let size_word (a: alg) : size_nat =
| numbytes (wt a) | false |
LowParse.Spec.List.fst | LowParse.Spec.List.tot_parse_list | val tot_parse_list
(#k: parser_kind)
(#t: Type)
(p: tot_parser k t)
: Pure (tot_parser parse_list_kind (list t))
(requires True)
(ensures (fun y ->
forall x . parse y x == parse (parse_list #k p) x
)) | val tot_parse_list
(#k: parser_kind)
(#t: Type)
(p: tot_parser k t)
: Pure (tot_parser parse_list_kind (list t))
(requires True)
(ensures (fun y ->
forall x . parse y x == parse (parse_list #k p) x
)) | let tot_parse_list #k #t p =
parser_kind_prop_ext parse_list_kind (parse_list #k p) (tot_parse_list_aux p);
tot_parse_list_aux p | {
"file_name": "src/lowparse/LowParse.Spec.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 22,
"end_line": 131,
"start_col": 0,
"start_line": 129
} | module LowParse.Spec.List
include LowParse.Spec.Combinators // for seq_slice_append_l
module Seq = FStar.Seq
module L = FStar.List.Tot
module U32 = FStar.UInt32
module Classical = FStar.Classical
(* Parse a list, until there is nothing left to read. This parser will mostly fail EXCEPT if the whole size is known and the slice has been suitably truncated beforehand, or if the elements of the list all have a known constant size. *)
#push-options "--z3rlimit 16"
let parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p)))
= parser_kind_prop_equiv k p;
let f () : Lemma
(injective p)
= ()
in
let rec aux
(b1: bytes)
(b2: bytes)
: Lemma
(requires (injective_precond (parse_list_bare p) b1 b2))
(ensures (injective_postcond (parse_list_bare p) b1 b2))
(decreases (Seq.length b1 + Seq.length b2))
= if Seq.length b1 = 0
then begin
() // assert (Seq.equal b1 b2)
end else begin
assert (injective_precond p b1 b2);
f ();
assert (injective_postcond p b1 b2);
let (Some (_, len1)) = parse p b1 in
let (Some (_, len2)) = parse p b2 in
assert ((len1 <: nat) == (len2 <: nat));
let b1' : bytes = Seq.slice b1 len1 (Seq.length b1) in
let b2' : bytes = Seq.slice b2 len2 (Seq.length b2) in
aux b1' b2';
let (Some (_, len1')) = parse (parse_list_bare p) b1' in
let (Some (_, len2')) = parse (parse_list_bare p) b2' in
Seq.lemma_split (Seq.slice b1 0 (len1 + len1')) len1;
Seq.lemma_split (Seq.slice b2 0 (len2 + len2')) len2;
assert (injective_postcond (parse_list_bare p) b1 b2)
end
in
Classical.forall_intro_2 (fun b -> Classical.move_requires (aux b))
#pop-options
let parse_list #k #t p =
parse_list_bare_injective p;
parse_list_bare_consumes_all p;
parser_kind_prop_equiv parse_list_kind (parse_list_bare p);
parse_list_bare p
let parse_list_eq
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
))
= ()
let parse_list_eq'
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(requires (k.parser_kind_low > 0))
(ensures (parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
begin match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
end
)))
= ()
let rec tot_parse_list_aux
(#k: parser_kind)
(#t: Type)
(p: tot_parser k t)
(b: bytes)
: Pure (option (list t * (consumed_length b)))
(requires True)
(ensures (fun y -> y == parse_list_aux #k p b))
(decreases (Seq.length b))
= if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match tot_parse_list_aux p (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Classical",
"short_module": "Classical"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"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
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: LowParse.Spec.Base.tot_parser k t
-> Prims.Pure (LowParse.Spec.Base.tot_parser LowParse.Spec.List.parse_list_kind (Prims.list t)) | Prims.Pure | []
| []
| [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.tot_parser",
"LowParse.Spec.List.tot_parse_list_aux",
"Prims.unit",
"LowParse.Spec.Base.parser_kind_prop_ext",
"Prims.list",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list"
]
| []
| false | false | false | false | false | let tot_parse_list #k #t p =
| parser_kind_prop_ext parse_list_kind (parse_list #k p) (tot_parse_list_aux p);
tot_parse_list_aux p | false |
LowParse.Spec.List.fst | LowParse.Spec.List.serialize_list_cons_upd_chain | val serialize_list_cons_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(x: t)
(l2: list t)
(y: t)
(i' : nat)
(s' : bytes)
: Lemma
(requires (
let sx = serialize s x in
serialize_list_precond k /\
i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'
))
(ensures (
let ln2 = Seq.length (serialize (serialize_list _ s) l2) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (x :: l2) in
Seq.length sl == Seq.length sx + ln2 /\
i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (y :: l2) == seq_upd_seq sl i' s'
)) | val serialize_list_cons_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(x: t)
(l2: list t)
(y: t)
(i' : nat)
(s' : bytes)
: Lemma
(requires (
let sx = serialize s x in
serialize_list_precond k /\
i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'
))
(ensures (
let ln2 = Seq.length (serialize (serialize_list _ s) l2) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (x :: l2) in
Seq.length sl == Seq.length sx + ln2 /\
i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (y :: l2) == seq_upd_seq sl i' s'
)) | let serialize_list_cons_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(x: t)
(l2: list t)
(y: t)
(i' : nat)
(s' : bytes)
: Lemma
(requires (
let sx = serialize s x in
serialize_list_precond k /\
i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'
))
(ensures (
let ln2 = Seq.length (serialize (serialize_list _ s) l2) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (x :: l2) in
Seq.length sl == Seq.length sx + ln2 /\
i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (y :: l2) == seq_upd_seq sl i' s'
))
= serialize_list_upd_chain s [] x l2 y i' s' | {
"file_name": "src/lowparse/LowParse.Spec.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 44,
"end_line": 265,
"start_col": 0,
"start_line": 240
} | module LowParse.Spec.List
include LowParse.Spec.Combinators // for seq_slice_append_l
module Seq = FStar.Seq
module L = FStar.List.Tot
module U32 = FStar.UInt32
module Classical = FStar.Classical
(* Parse a list, until there is nothing left to read. This parser will mostly fail EXCEPT if the whole size is known and the slice has been suitably truncated beforehand, or if the elements of the list all have a known constant size. *)
#push-options "--z3rlimit 16"
let parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p)))
= parser_kind_prop_equiv k p;
let f () : Lemma
(injective p)
= ()
in
let rec aux
(b1: bytes)
(b2: bytes)
: Lemma
(requires (injective_precond (parse_list_bare p) b1 b2))
(ensures (injective_postcond (parse_list_bare p) b1 b2))
(decreases (Seq.length b1 + Seq.length b2))
= if Seq.length b1 = 0
then begin
() // assert (Seq.equal b1 b2)
end else begin
assert (injective_precond p b1 b2);
f ();
assert (injective_postcond p b1 b2);
let (Some (_, len1)) = parse p b1 in
let (Some (_, len2)) = parse p b2 in
assert ((len1 <: nat) == (len2 <: nat));
let b1' : bytes = Seq.slice b1 len1 (Seq.length b1) in
let b2' : bytes = Seq.slice b2 len2 (Seq.length b2) in
aux b1' b2';
let (Some (_, len1')) = parse (parse_list_bare p) b1' in
let (Some (_, len2')) = parse (parse_list_bare p) b2' in
Seq.lemma_split (Seq.slice b1 0 (len1 + len1')) len1;
Seq.lemma_split (Seq.slice b2 0 (len2 + len2')) len2;
assert (injective_postcond (parse_list_bare p) b1 b2)
end
in
Classical.forall_intro_2 (fun b -> Classical.move_requires (aux b))
#pop-options
let parse_list #k #t p =
parse_list_bare_injective p;
parse_list_bare_consumes_all p;
parser_kind_prop_equiv parse_list_kind (parse_list_bare p);
parse_list_bare p
let parse_list_eq
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
))
= ()
let parse_list_eq'
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(requires (k.parser_kind_low > 0))
(ensures (parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
begin match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
end
)))
= ()
let rec tot_parse_list_aux
(#k: parser_kind)
(#t: Type)
(p: tot_parser k t)
(b: bytes)
: Pure (option (list t * (consumed_length b)))
(requires True)
(ensures (fun y -> y == parse_list_aux #k p b))
(decreases (Seq.length b))
= if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match tot_parse_list_aux p (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
let tot_parse_list #k #t p =
parser_kind_prop_ext parse_list_kind (parse_list #k p) (tot_parse_list_aux p);
tot_parse_list_aux p
let bare_serialize_list_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (serialize_list_precond k))
(ensures (serializer_correct (parse_list p) (bare_serialize_list p s)))
= parser_kind_prop_equiv k p;
let f () : Lemma (serialize_list_precond k) = () in
let rec prf
(l: list t)
: Lemma
(parse (parse_list p) (bare_serialize_list p s l) == Some (l, Seq.length (bare_serialize_list p s l)))
= match l with
| [] -> ()
| a :: q ->
let pa = parse p (bare_serialize_list p s l) in
f ();
parser_kind_prop_equiv k p;
assert (no_lookahead_on p (serialize s a) (bare_serialize_list p s l));
seq_slice_append_l (serialize s a) (bare_serialize_list p s q);
assert (no_lookahead_on_precond p (serialize s a) (bare_serialize_list p s l));
assert (no_lookahead_on_postcond p (serialize s a) (bare_serialize_list p s l));
assert (Some? pa);
assert (injective_precond p (serialize s a) (bare_serialize_list p s l));
assert (injective_postcond p (serialize s a) (bare_serialize_list p s l));
let (Some (a', lena)) = pa in
assert (a == a');
assert (lena == Seq.length (serialize s a));
assert (lena > 0);
prf q;
seq_slice_append_r (serialize s a) (bare_serialize_list p s q)
in
Classical.forall_intro prf
let serialize_list
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Pure (serializer (parse_list p))
(requires (
serialize_list_precond k
))
(ensures (fun _ -> True))
= bare_serialize_list_correct p s;
bare_serialize_list p s
let serialize_list_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (serialize (serialize_list p s) [] == Seq.empty))
= ()
let serialize_list_cons
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
(q: list t)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (
serialize (serialize_list p s) (a :: q) == Seq.append (serialize s a) (serialize (serialize_list p s) q)
))
= ()
let serialize_list_singleton
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) [a] == serialize s a))
= Seq.append_empty_r (serialize s a)
let rec serialize_list_append
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(l1 l2: list t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) (L.append l1 l2) == Seq.append (serialize (serialize_list p s) l1) (serialize (serialize_list p s) l2)))
= match l1 with
| a :: q ->
serialize_list_append p s q l2;
Seq.append_assoc (serialize s a) (serialize (serialize_list p s) q) (serialize (serialize_list p s) l2)
| [] ->
Seq.append_empty_l (serialize (serialize_list p s) l2)
#push-options "--z3rlimit 64" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Classical",
"short_module": "Classical"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"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
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 64,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s: LowParse.Spec.Base.serializer p ->
x: t ->
l2: Prims.list t ->
y: t ->
i': Prims.nat ->
s': LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(requires
(let sx = LowParse.Spec.Base.serialize s x in
LowParse.Spec.List.serialize_list_precond k /\
i' + FStar.Seq.Base.length s' <= FStar.Seq.Base.length sx /\
LowParse.Spec.Base.serialize s y == LowParse.Spec.Base.seq_upd_seq sx i' s'))
(ensures
(let ln2 =
FStar.Seq.Base.length (LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p
s)
l2)
in
let sx = LowParse.Spec.Base.serialize s x in
let sl = LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p s) (x :: l2) in
FStar.Seq.Base.length sl == FStar.Seq.Base.length sx + ln2 /\
i' + FStar.Seq.Base.length s' <= FStar.Seq.Base.length sl /\
LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p s) (y :: l2) ==
LowParse.Spec.Base.seq_upd_seq sl i' s')) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"Prims.list",
"Prims.nat",
"LowParse.Bytes.bytes",
"LowParse.Spec.List.serialize_list_upd_chain",
"Prims.Nil",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.eq2",
"FStar.Seq.Base.seq",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.Base.seq_upd_seq",
"Prims.squash",
"Prims.int",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.serialize_list",
"Prims.Cons",
"FStar.Pervasives.pattern"
]
| []
| true | false | true | false | false | let serialize_list_cons_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(x: t)
(l2: list t)
(y: t)
(i': nat)
(s': bytes)
: Lemma
(requires
(let sx = serialize s x in
serialize_list_precond k /\ i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'))
(ensures
(let ln2 = Seq.length (serialize (serialize_list _ s) l2) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (x :: l2) in
Seq.length sl == Seq.length sx + ln2 /\ i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (y :: l2) == seq_upd_seq sl i' s')) =
| serialize_list_upd_chain s [] x l2 y i' s' | false |
LowParse.Spec.List.fst | LowParse.Spec.List.serialize_list_append | val serialize_list_append
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(l1 l2: list t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) (L.append l1 l2) == Seq.append (serialize (serialize_list p s) l1) (serialize (serialize_list p s) l2))) | val serialize_list_append
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(l1 l2: list t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) (L.append l1 l2) == Seq.append (serialize (serialize_list p s) l1) (serialize (serialize_list p s) l2))) | let rec serialize_list_append
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(l1 l2: list t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) (L.append l1 l2) == Seq.append (serialize (serialize_list p s) l1) (serialize (serialize_list p s) l2)))
= match l1 with
| a :: q ->
serialize_list_append p s q l2;
Seq.append_assoc (serialize s a) (serialize (serialize_list p s) q) (serialize (serialize_list p s) l2)
| [] ->
Seq.append_empty_l (serialize (serialize_list p s) l2) | {
"file_name": "src/lowparse/LowParse.Spec.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 58,
"end_line": 235,
"start_col": 0,
"start_line": 221
} | module LowParse.Spec.List
include LowParse.Spec.Combinators // for seq_slice_append_l
module Seq = FStar.Seq
module L = FStar.List.Tot
module U32 = FStar.UInt32
module Classical = FStar.Classical
(* Parse a list, until there is nothing left to read. This parser will mostly fail EXCEPT if the whole size is known and the slice has been suitably truncated beforehand, or if the elements of the list all have a known constant size. *)
#push-options "--z3rlimit 16"
let parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p)))
= parser_kind_prop_equiv k p;
let f () : Lemma
(injective p)
= ()
in
let rec aux
(b1: bytes)
(b2: bytes)
: Lemma
(requires (injective_precond (parse_list_bare p) b1 b2))
(ensures (injective_postcond (parse_list_bare p) b1 b2))
(decreases (Seq.length b1 + Seq.length b2))
= if Seq.length b1 = 0
then begin
() // assert (Seq.equal b1 b2)
end else begin
assert (injective_precond p b1 b2);
f ();
assert (injective_postcond p b1 b2);
let (Some (_, len1)) = parse p b1 in
let (Some (_, len2)) = parse p b2 in
assert ((len1 <: nat) == (len2 <: nat));
let b1' : bytes = Seq.slice b1 len1 (Seq.length b1) in
let b2' : bytes = Seq.slice b2 len2 (Seq.length b2) in
aux b1' b2';
let (Some (_, len1')) = parse (parse_list_bare p) b1' in
let (Some (_, len2')) = parse (parse_list_bare p) b2' in
Seq.lemma_split (Seq.slice b1 0 (len1 + len1')) len1;
Seq.lemma_split (Seq.slice b2 0 (len2 + len2')) len2;
assert (injective_postcond (parse_list_bare p) b1 b2)
end
in
Classical.forall_intro_2 (fun b -> Classical.move_requires (aux b))
#pop-options
let parse_list #k #t p =
parse_list_bare_injective p;
parse_list_bare_consumes_all p;
parser_kind_prop_equiv parse_list_kind (parse_list_bare p);
parse_list_bare p
let parse_list_eq
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
))
= ()
let parse_list_eq'
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(requires (k.parser_kind_low > 0))
(ensures (parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
begin match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
end
)))
= ()
let rec tot_parse_list_aux
(#k: parser_kind)
(#t: Type)
(p: tot_parser k t)
(b: bytes)
: Pure (option (list t * (consumed_length b)))
(requires True)
(ensures (fun y -> y == parse_list_aux #k p b))
(decreases (Seq.length b))
= if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match tot_parse_list_aux p (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
let tot_parse_list #k #t p =
parser_kind_prop_ext parse_list_kind (parse_list #k p) (tot_parse_list_aux p);
tot_parse_list_aux p
let bare_serialize_list_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (serialize_list_precond k))
(ensures (serializer_correct (parse_list p) (bare_serialize_list p s)))
= parser_kind_prop_equiv k p;
let f () : Lemma (serialize_list_precond k) = () in
let rec prf
(l: list t)
: Lemma
(parse (parse_list p) (bare_serialize_list p s l) == Some (l, Seq.length (bare_serialize_list p s l)))
= match l with
| [] -> ()
| a :: q ->
let pa = parse p (bare_serialize_list p s l) in
f ();
parser_kind_prop_equiv k p;
assert (no_lookahead_on p (serialize s a) (bare_serialize_list p s l));
seq_slice_append_l (serialize s a) (bare_serialize_list p s q);
assert (no_lookahead_on_precond p (serialize s a) (bare_serialize_list p s l));
assert (no_lookahead_on_postcond p (serialize s a) (bare_serialize_list p s l));
assert (Some? pa);
assert (injective_precond p (serialize s a) (bare_serialize_list p s l));
assert (injective_postcond p (serialize s a) (bare_serialize_list p s l));
let (Some (a', lena)) = pa in
assert (a == a');
assert (lena == Seq.length (serialize s a));
assert (lena > 0);
prf q;
seq_slice_append_r (serialize s a) (bare_serialize_list p s q)
in
Classical.forall_intro prf
let serialize_list
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Pure (serializer (parse_list p))
(requires (
serialize_list_precond k
))
(ensures (fun _ -> True))
= bare_serialize_list_correct p s;
bare_serialize_list p s
let serialize_list_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (serialize (serialize_list p s) [] == Seq.empty))
= ()
let serialize_list_cons
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
(q: list t)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (
serialize (serialize_list p s) (a :: q) == Seq.append (serialize s a) (serialize (serialize_list p s) q)
))
= ()
let serialize_list_singleton
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) [a] == serialize s a))
= Seq.append_empty_r (serialize s a) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Classical",
"short_module": "Classical"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"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
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
p: LowParse.Spec.Base.parser k t ->
s: LowParse.Spec.Base.serializer p ->
l1: Prims.list t ->
l2: Prims.list t
-> FStar.Pervasives.Lemma (requires LowParse.Spec.List.serialize_list_precond k)
(ensures
LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p s) (l1 @ l2) ==
FStar.Seq.Base.append (LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p s)
l1)
(LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p s) l2)) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"Prims.list",
"FStar.Seq.Base.append_assoc",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.serialize_list",
"Prims.unit",
"LowParse.Spec.List.serialize_list_append",
"FStar.Seq.Base.append_empty_l",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.squash",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.List.Tot.Base.append",
"FStar.Seq.Base.append",
"Prims.Nil",
"FStar.Pervasives.pattern"
]
| [
"recursion"
]
| false | false | true | false | false | let rec serialize_list_append
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(l1 l2: list t)
: Lemma (requires (serialize_list_precond k))
(ensures
(serialize (serialize_list p s) (L.append l1 l2) ==
Seq.append (serialize (serialize_list p s) l1) (serialize (serialize_list p s) l2))) =
| match l1 with
| a :: q ->
serialize_list_append p s q l2;
Seq.append_assoc (serialize s a)
(serialize (serialize_list p s) q)
(serialize (serialize_list p s) l2)
| [] -> Seq.append_empty_l (serialize (serialize_list p s) l2) | false |
LowParse.Spec.List.fst | LowParse.Spec.List.serialize_list_singleton | val serialize_list_singleton
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) [a] == serialize s a)) | val serialize_list_singleton
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) [a] == serialize s a)) | let serialize_list_singleton
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) [a] == serialize s a))
= Seq.append_empty_r (serialize s a) | {
"file_name": "src/lowparse/LowParse.Spec.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 36,
"end_line": 219,
"start_col": 0,
"start_line": 210
} | module LowParse.Spec.List
include LowParse.Spec.Combinators // for seq_slice_append_l
module Seq = FStar.Seq
module L = FStar.List.Tot
module U32 = FStar.UInt32
module Classical = FStar.Classical
(* Parse a list, until there is nothing left to read. This parser will mostly fail EXCEPT if the whole size is known and the slice has been suitably truncated beforehand, or if the elements of the list all have a known constant size. *)
#push-options "--z3rlimit 16"
let parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p)))
= parser_kind_prop_equiv k p;
let f () : Lemma
(injective p)
= ()
in
let rec aux
(b1: bytes)
(b2: bytes)
: Lemma
(requires (injective_precond (parse_list_bare p) b1 b2))
(ensures (injective_postcond (parse_list_bare p) b1 b2))
(decreases (Seq.length b1 + Seq.length b2))
= if Seq.length b1 = 0
then begin
() // assert (Seq.equal b1 b2)
end else begin
assert (injective_precond p b1 b2);
f ();
assert (injective_postcond p b1 b2);
let (Some (_, len1)) = parse p b1 in
let (Some (_, len2)) = parse p b2 in
assert ((len1 <: nat) == (len2 <: nat));
let b1' : bytes = Seq.slice b1 len1 (Seq.length b1) in
let b2' : bytes = Seq.slice b2 len2 (Seq.length b2) in
aux b1' b2';
let (Some (_, len1')) = parse (parse_list_bare p) b1' in
let (Some (_, len2')) = parse (parse_list_bare p) b2' in
Seq.lemma_split (Seq.slice b1 0 (len1 + len1')) len1;
Seq.lemma_split (Seq.slice b2 0 (len2 + len2')) len2;
assert (injective_postcond (parse_list_bare p) b1 b2)
end
in
Classical.forall_intro_2 (fun b -> Classical.move_requires (aux b))
#pop-options
let parse_list #k #t p =
parse_list_bare_injective p;
parse_list_bare_consumes_all p;
parser_kind_prop_equiv parse_list_kind (parse_list_bare p);
parse_list_bare p
let parse_list_eq
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
))
= ()
let parse_list_eq'
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(requires (k.parser_kind_low > 0))
(ensures (parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
begin match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
end
)))
= ()
let rec tot_parse_list_aux
(#k: parser_kind)
(#t: Type)
(p: tot_parser k t)
(b: bytes)
: Pure (option (list t * (consumed_length b)))
(requires True)
(ensures (fun y -> y == parse_list_aux #k p b))
(decreases (Seq.length b))
= if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match tot_parse_list_aux p (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
let tot_parse_list #k #t p =
parser_kind_prop_ext parse_list_kind (parse_list #k p) (tot_parse_list_aux p);
tot_parse_list_aux p
let bare_serialize_list_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (serialize_list_precond k))
(ensures (serializer_correct (parse_list p) (bare_serialize_list p s)))
= parser_kind_prop_equiv k p;
let f () : Lemma (serialize_list_precond k) = () in
let rec prf
(l: list t)
: Lemma
(parse (parse_list p) (bare_serialize_list p s l) == Some (l, Seq.length (bare_serialize_list p s l)))
= match l with
| [] -> ()
| a :: q ->
let pa = parse p (bare_serialize_list p s l) in
f ();
parser_kind_prop_equiv k p;
assert (no_lookahead_on p (serialize s a) (bare_serialize_list p s l));
seq_slice_append_l (serialize s a) (bare_serialize_list p s q);
assert (no_lookahead_on_precond p (serialize s a) (bare_serialize_list p s l));
assert (no_lookahead_on_postcond p (serialize s a) (bare_serialize_list p s l));
assert (Some? pa);
assert (injective_precond p (serialize s a) (bare_serialize_list p s l));
assert (injective_postcond p (serialize s a) (bare_serialize_list p s l));
let (Some (a', lena)) = pa in
assert (a == a');
assert (lena == Seq.length (serialize s a));
assert (lena > 0);
prf q;
seq_slice_append_r (serialize s a) (bare_serialize_list p s q)
in
Classical.forall_intro prf
let serialize_list
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Pure (serializer (parse_list p))
(requires (
serialize_list_precond k
))
(ensures (fun _ -> True))
= bare_serialize_list_correct p s;
bare_serialize_list p s
let serialize_list_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (serialize (serialize_list p s) [] == Seq.empty))
= ()
let serialize_list_cons
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
(q: list t)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (
serialize (serialize_list p s) (a :: q) == Seq.append (serialize s a) (serialize (serialize_list p s) q)
))
= () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Classical",
"short_module": "Classical"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"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
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: LowParse.Spec.Base.parser k t -> s: LowParse.Spec.Base.serializer p -> a: t
-> FStar.Pervasives.Lemma (requires LowParse.Spec.List.serialize_list_precond k)
(ensures
LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p s) [a] ==
LowParse.Spec.Base.serialize s a) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"FStar.Seq.Base.append_empty_r",
"LowParse.Bytes.byte",
"LowParse.Spec.Base.serialize",
"Prims.unit",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.squash",
"Prims.eq2",
"LowParse.Bytes.bytes",
"LowParse.Spec.List.parse_list_kind",
"Prims.list",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.serialize_list",
"Prims.Cons",
"Prims.Nil",
"FStar.Pervasives.pattern"
]
| []
| true | false | true | false | false | let serialize_list_singleton (#k: parser_kind) (#t: Type) (p: parser k t) (s: serializer p) (a: t)
: Lemma (requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) [a] == serialize s a)) =
| Seq.append_empty_r (serialize s a) | false |
LowParse.Spec.List.fst | LowParse.Spec.List.serialize_list_snoc_upd_chain | val serialize_list_snoc_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(l1: list t)
(x: t)
(y: t)
(i' : nat)
(s' : bytes)
: Lemma
(requires (
let sx = serialize s x in
serialize_list_precond k /\
i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'
))
(ensures (
let ln1 = Seq.length (serialize (serialize_list _ s) l1) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (l1 `L.append` [x]) in
Seq.length sl == ln1 + Seq.length sx /\
ln1 + i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (l1 `L.append` [y]) == seq_upd_seq sl (ln1 + i') s'
)) | val serialize_list_snoc_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(l1: list t)
(x: t)
(y: t)
(i' : nat)
(s' : bytes)
: Lemma
(requires (
let sx = serialize s x in
serialize_list_precond k /\
i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'
))
(ensures (
let ln1 = Seq.length (serialize (serialize_list _ s) l1) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (l1 `L.append` [x]) in
Seq.length sl == ln1 + Seq.length sx /\
ln1 + i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (l1 `L.append` [y]) == seq_upd_seq sl (ln1 + i') s'
)) | let serialize_list_snoc_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(l1: list t)
(x: t)
(y: t)
(i' : nat)
(s' : bytes)
: Lemma
(requires (
let sx = serialize s x in
serialize_list_precond k /\
i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'
))
(ensures (
let ln1 = Seq.length (serialize (serialize_list _ s) l1) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (l1 `L.append` [x]) in
Seq.length sl == ln1 + Seq.length sx /\
ln1 + i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (l1 `L.append` [y]) == seq_upd_seq sl (ln1 + i') s'
))
= serialize_list_upd_chain s l1 x [] y i' s' | {
"file_name": "src/lowparse/LowParse.Spec.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 44,
"end_line": 292,
"start_col": 0,
"start_line": 267
} | module LowParse.Spec.List
include LowParse.Spec.Combinators // for seq_slice_append_l
module Seq = FStar.Seq
module L = FStar.List.Tot
module U32 = FStar.UInt32
module Classical = FStar.Classical
(* Parse a list, until there is nothing left to read. This parser will mostly fail EXCEPT if the whole size is known and the slice has been suitably truncated beforehand, or if the elements of the list all have a known constant size. *)
#push-options "--z3rlimit 16"
let parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p)))
= parser_kind_prop_equiv k p;
let f () : Lemma
(injective p)
= ()
in
let rec aux
(b1: bytes)
(b2: bytes)
: Lemma
(requires (injective_precond (parse_list_bare p) b1 b2))
(ensures (injective_postcond (parse_list_bare p) b1 b2))
(decreases (Seq.length b1 + Seq.length b2))
= if Seq.length b1 = 0
then begin
() // assert (Seq.equal b1 b2)
end else begin
assert (injective_precond p b1 b2);
f ();
assert (injective_postcond p b1 b2);
let (Some (_, len1)) = parse p b1 in
let (Some (_, len2)) = parse p b2 in
assert ((len1 <: nat) == (len2 <: nat));
let b1' : bytes = Seq.slice b1 len1 (Seq.length b1) in
let b2' : bytes = Seq.slice b2 len2 (Seq.length b2) in
aux b1' b2';
let (Some (_, len1')) = parse (parse_list_bare p) b1' in
let (Some (_, len2')) = parse (parse_list_bare p) b2' in
Seq.lemma_split (Seq.slice b1 0 (len1 + len1')) len1;
Seq.lemma_split (Seq.slice b2 0 (len2 + len2')) len2;
assert (injective_postcond (parse_list_bare p) b1 b2)
end
in
Classical.forall_intro_2 (fun b -> Classical.move_requires (aux b))
#pop-options
let parse_list #k #t p =
parse_list_bare_injective p;
parse_list_bare_consumes_all p;
parser_kind_prop_equiv parse_list_kind (parse_list_bare p);
parse_list_bare p
let parse_list_eq
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
))
= ()
let parse_list_eq'
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(requires (k.parser_kind_low > 0))
(ensures (parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
begin match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
end
)))
= ()
let rec tot_parse_list_aux
(#k: parser_kind)
(#t: Type)
(p: tot_parser k t)
(b: bytes)
: Pure (option (list t * (consumed_length b)))
(requires True)
(ensures (fun y -> y == parse_list_aux #k p b))
(decreases (Seq.length b))
= if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match tot_parse_list_aux p (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
let tot_parse_list #k #t p =
parser_kind_prop_ext parse_list_kind (parse_list #k p) (tot_parse_list_aux p);
tot_parse_list_aux p
let bare_serialize_list_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (serialize_list_precond k))
(ensures (serializer_correct (parse_list p) (bare_serialize_list p s)))
= parser_kind_prop_equiv k p;
let f () : Lemma (serialize_list_precond k) = () in
let rec prf
(l: list t)
: Lemma
(parse (parse_list p) (bare_serialize_list p s l) == Some (l, Seq.length (bare_serialize_list p s l)))
= match l with
| [] -> ()
| a :: q ->
let pa = parse p (bare_serialize_list p s l) in
f ();
parser_kind_prop_equiv k p;
assert (no_lookahead_on p (serialize s a) (bare_serialize_list p s l));
seq_slice_append_l (serialize s a) (bare_serialize_list p s q);
assert (no_lookahead_on_precond p (serialize s a) (bare_serialize_list p s l));
assert (no_lookahead_on_postcond p (serialize s a) (bare_serialize_list p s l));
assert (Some? pa);
assert (injective_precond p (serialize s a) (bare_serialize_list p s l));
assert (injective_postcond p (serialize s a) (bare_serialize_list p s l));
let (Some (a', lena)) = pa in
assert (a == a');
assert (lena == Seq.length (serialize s a));
assert (lena > 0);
prf q;
seq_slice_append_r (serialize s a) (bare_serialize_list p s q)
in
Classical.forall_intro prf
let serialize_list
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Pure (serializer (parse_list p))
(requires (
serialize_list_precond k
))
(ensures (fun _ -> True))
= bare_serialize_list_correct p s;
bare_serialize_list p s
let serialize_list_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (serialize (serialize_list p s) [] == Seq.empty))
= ()
let serialize_list_cons
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
(q: list t)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (
serialize (serialize_list p s) (a :: q) == Seq.append (serialize s a) (serialize (serialize_list p s) q)
))
= ()
let serialize_list_singleton
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) [a] == serialize s a))
= Seq.append_empty_r (serialize s a)
let rec serialize_list_append
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(l1 l2: list t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) (L.append l1 l2) == Seq.append (serialize (serialize_list p s) l1) (serialize (serialize_list p s) l2)))
= match l1 with
| a :: q ->
serialize_list_append p s q l2;
Seq.append_assoc (serialize s a) (serialize (serialize_list p s) q) (serialize (serialize_list p s) l2)
| [] ->
Seq.append_empty_l (serialize (serialize_list p s) l2)
#push-options "--z3rlimit 64"
let serialize_list_cons_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(x: t)
(l2: list t)
(y: t)
(i' : nat)
(s' : bytes)
: Lemma
(requires (
let sx = serialize s x in
serialize_list_precond k /\
i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'
))
(ensures (
let ln2 = Seq.length (serialize (serialize_list _ s) l2) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (x :: l2) in
Seq.length sl == Seq.length sx + ln2 /\
i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (y :: l2) == seq_upd_seq sl i' s'
))
= serialize_list_upd_chain s [] x l2 y i' s' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Classical",
"short_module": "Classical"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"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
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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": 64,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
s: LowParse.Spec.Base.serializer p ->
l1: Prims.list t ->
x: t ->
y: t ->
i': Prims.nat ->
s': LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(requires
(let sx = LowParse.Spec.Base.serialize s x in
LowParse.Spec.List.serialize_list_precond k /\
i' + FStar.Seq.Base.length s' <= FStar.Seq.Base.length sx /\
LowParse.Spec.Base.serialize s y == LowParse.Spec.Base.seq_upd_seq sx i' s'))
(ensures
(let ln1 =
FStar.Seq.Base.length (LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p
s)
l1)
in
let sx = LowParse.Spec.Base.serialize s x in
let sl =
LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p s) (l1 @ [x])
in
FStar.Seq.Base.length sl == ln1 + FStar.Seq.Base.length sx /\
ln1 + i' + FStar.Seq.Base.length s' <= FStar.Seq.Base.length sl /\
LowParse.Spec.Base.serialize (LowParse.Spec.List.serialize_list p s) (l1 @ [y]) ==
LowParse.Spec.Base.seq_upd_seq sl (ln1 + i') s')) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"Prims.list",
"Prims.nat",
"LowParse.Bytes.bytes",
"LowParse.Spec.List.serialize_list_upd_chain",
"Prims.Nil",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"LowParse.Spec.List.serialize_list_precond",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.eq2",
"FStar.Seq.Base.seq",
"LowParse.Spec.Base.serialize",
"LowParse.Spec.Base.seq_upd_seq",
"Prims.squash",
"Prims.int",
"LowParse.Spec.List.parse_list_kind",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.serialize_list",
"FStar.List.Tot.Base.append",
"Prims.Cons",
"FStar.Pervasives.pattern"
]
| []
| true | false | true | false | false | let serialize_list_snoc_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(l1: list t)
(x y: t)
(i': nat)
(s': bytes)
: Lemma
(requires
(let sx = serialize s x in
serialize_list_precond k /\ i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'))
(ensures
(let ln1 = Seq.length (serialize (serialize_list _ s) l1) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (l1 `L.append` [x]) in
Seq.length sl == ln1 + Seq.length sx /\ ln1 + i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (l1 `L.append` [y]) == seq_upd_seq sl (ln1 + i') s')) =
| serialize_list_upd_chain s l1 x [] y i' s' | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.get_blake2s_salt | val get_blake2s_salt : p: Spec.Blake2.Definitions.blake2s_params
-> Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(Spec.Blake2.Definitions.salt_length Spec.Blake2.Definitions.Blake2S) | let get_blake2s_salt (p:blake2s_params) = p.salt | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 124,
"start_col": 0,
"start_line": 124
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: Spec.Blake2.Definitions.blake2s_params
-> Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(Spec.Blake2.Definitions.salt_length Spec.Blake2.Definitions.Blake2S) | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.blake2s_params",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__salt",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Blake2.Definitions.salt_length",
"Spec.Blake2.Definitions.Blake2S"
]
| []
| false | false | false | true | false | let get_blake2s_salt (p: blake2s_params) =
| p.salt | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.get_blake2s_personal | val get_blake2s_personal : p: Spec.Blake2.Definitions.blake2s_params
-> Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(Spec.Blake2.Definitions.personal_length Spec.Blake2.Definitions.Blake2S) | let get_blake2s_personal (p:blake2s_params) = p.personal | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 56,
"end_line": 127,
"start_col": 0,
"start_line": 127
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: Spec.Blake2.Definitions.blake2s_params
-> Lib.Sequence.lseq (Lib.IntTypes.int_t Lib.IntTypes.U8 Lib.IntTypes.SEC)
(Spec.Blake2.Definitions.personal_length Spec.Blake2.Definitions.Blake2S) | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.blake2s_params",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__personal",
"Lib.Sequence.lseq",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Blake2.Definitions.personal_length",
"Spec.Blake2.Definitions.Blake2S"
]
| []
| false | false | false | true | false | let get_blake2s_personal (p: blake2s_params) =
| p.personal | false |
|
LowParse.Spec.List.fst | LowParse.Spec.List.list_length_constant_size_parser_correct | val list_length_constant_size_parser_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(requires (
k.parser_kind_high == Some k.parser_kind_low /\
Some? (parse (parse_list p) b)
))
(ensures (
let pb = parse (parse_list p) b in
Some? pb /\ (
let (Some (l, _)) = pb in
FStar.Mul.op_Star (L.length l) k.parser_kind_low == Seq.length b
)))
(decreases (Seq.length b)) | val list_length_constant_size_parser_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(requires (
k.parser_kind_high == Some k.parser_kind_low /\
Some? (parse (parse_list p) b)
))
(ensures (
let pb = parse (parse_list p) b in
Some? pb /\ (
let (Some (l, _)) = pb in
FStar.Mul.op_Star (L.length l) k.parser_kind_low == Seq.length b
)))
(decreases (Seq.length b)) | let rec list_length_constant_size_parser_correct #k #t p b =
parser_kind_prop_equiv k p;
let n = k.parser_kind_low in
if Seq.length b = 0
then ()
else begin
let (Some (_, consumed)) = parse p b in
assert ((consumed <: nat) == n);
assert (n > 0);
let b' : bytes = Seq.slice b n (Seq.length b) in
list_length_constant_size_parser_correct p b';
let (Some (l', _)) = parse (parse_list p) b' in
FStar.Math.Lemmas.distributivity_add_left 1 (L.length l') n
end | {
"file_name": "src/lowparse/LowParse.Spec.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 5,
"end_line": 309,
"start_col": 0,
"start_line": 296
} | module LowParse.Spec.List
include LowParse.Spec.Combinators // for seq_slice_append_l
module Seq = FStar.Seq
module L = FStar.List.Tot
module U32 = FStar.UInt32
module Classical = FStar.Classical
(* Parse a list, until there is nothing left to read. This parser will mostly fail EXCEPT if the whole size is known and the slice has been suitably truncated beforehand, or if the elements of the list all have a known constant size. *)
#push-options "--z3rlimit 16"
let parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p)))
= parser_kind_prop_equiv k p;
let f () : Lemma
(injective p)
= ()
in
let rec aux
(b1: bytes)
(b2: bytes)
: Lemma
(requires (injective_precond (parse_list_bare p) b1 b2))
(ensures (injective_postcond (parse_list_bare p) b1 b2))
(decreases (Seq.length b1 + Seq.length b2))
= if Seq.length b1 = 0
then begin
() // assert (Seq.equal b1 b2)
end else begin
assert (injective_precond p b1 b2);
f ();
assert (injective_postcond p b1 b2);
let (Some (_, len1)) = parse p b1 in
let (Some (_, len2)) = parse p b2 in
assert ((len1 <: nat) == (len2 <: nat));
let b1' : bytes = Seq.slice b1 len1 (Seq.length b1) in
let b2' : bytes = Seq.slice b2 len2 (Seq.length b2) in
aux b1' b2';
let (Some (_, len1')) = parse (parse_list_bare p) b1' in
let (Some (_, len2')) = parse (parse_list_bare p) b2' in
Seq.lemma_split (Seq.slice b1 0 (len1 + len1')) len1;
Seq.lemma_split (Seq.slice b2 0 (len2 + len2')) len2;
assert (injective_postcond (parse_list_bare p) b1 b2)
end
in
Classical.forall_intro_2 (fun b -> Classical.move_requires (aux b))
#pop-options
let parse_list #k #t p =
parse_list_bare_injective p;
parse_list_bare_consumes_all p;
parser_kind_prop_equiv parse_list_kind (parse_list_bare p);
parse_list_bare p
let parse_list_eq
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
))
= ()
let parse_list_eq'
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(requires (k.parser_kind_low > 0))
(ensures (parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
begin match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
end
)))
= ()
let rec tot_parse_list_aux
(#k: parser_kind)
(#t: Type)
(p: tot_parser k t)
(b: bytes)
: Pure (option (list t * (consumed_length b)))
(requires True)
(ensures (fun y -> y == parse_list_aux #k p b))
(decreases (Seq.length b))
= if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match tot_parse_list_aux p (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
let tot_parse_list #k #t p =
parser_kind_prop_ext parse_list_kind (parse_list #k p) (tot_parse_list_aux p);
tot_parse_list_aux p
let bare_serialize_list_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (serialize_list_precond k))
(ensures (serializer_correct (parse_list p) (bare_serialize_list p s)))
= parser_kind_prop_equiv k p;
let f () : Lemma (serialize_list_precond k) = () in
let rec prf
(l: list t)
: Lemma
(parse (parse_list p) (bare_serialize_list p s l) == Some (l, Seq.length (bare_serialize_list p s l)))
= match l with
| [] -> ()
| a :: q ->
let pa = parse p (bare_serialize_list p s l) in
f ();
parser_kind_prop_equiv k p;
assert (no_lookahead_on p (serialize s a) (bare_serialize_list p s l));
seq_slice_append_l (serialize s a) (bare_serialize_list p s q);
assert (no_lookahead_on_precond p (serialize s a) (bare_serialize_list p s l));
assert (no_lookahead_on_postcond p (serialize s a) (bare_serialize_list p s l));
assert (Some? pa);
assert (injective_precond p (serialize s a) (bare_serialize_list p s l));
assert (injective_postcond p (serialize s a) (bare_serialize_list p s l));
let (Some (a', lena)) = pa in
assert (a == a');
assert (lena == Seq.length (serialize s a));
assert (lena > 0);
prf q;
seq_slice_append_r (serialize s a) (bare_serialize_list p s q)
in
Classical.forall_intro prf
let serialize_list
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Pure (serializer (parse_list p))
(requires (
serialize_list_precond k
))
(ensures (fun _ -> True))
= bare_serialize_list_correct p s;
bare_serialize_list p s
let serialize_list_nil
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (serialize (serialize_list p s) [] == Seq.empty))
= ()
let serialize_list_cons
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
(q: list t)
: Lemma
(requires (
serialize_list_precond k
))
(ensures (
serialize (serialize_list p s) (a :: q) == Seq.append (serialize s a) (serialize (serialize_list p s) q)
))
= ()
let serialize_list_singleton
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(a: t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) [a] == serialize s a))
= Seq.append_empty_r (serialize s a)
let rec serialize_list_append
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
(l1 l2: list t)
: Lemma
(requires (serialize_list_precond k))
(ensures (serialize (serialize_list p s) (L.append l1 l2) == Seq.append (serialize (serialize_list p s) l1) (serialize (serialize_list p s) l2)))
= match l1 with
| a :: q ->
serialize_list_append p s q l2;
Seq.append_assoc (serialize s a) (serialize (serialize_list p s) q) (serialize (serialize_list p s) l2)
| [] ->
Seq.append_empty_l (serialize (serialize_list p s) l2)
#push-options "--z3rlimit 64"
let serialize_list_cons_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(x: t)
(l2: list t)
(y: t)
(i' : nat)
(s' : bytes)
: Lemma
(requires (
let sx = serialize s x in
serialize_list_precond k /\
i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'
))
(ensures (
let ln2 = Seq.length (serialize (serialize_list _ s) l2) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (x :: l2) in
Seq.length sl == Seq.length sx + ln2 /\
i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (y :: l2) == seq_upd_seq sl i' s'
))
= serialize_list_upd_chain s [] x l2 y i' s'
let serialize_list_snoc_upd_chain
(#k: parser_kind)
(#t: Type)
(#p: parser k t)
(s: serializer p)
(l1: list t)
(x: t)
(y: t)
(i' : nat)
(s' : bytes)
: Lemma
(requires (
let sx = serialize s x in
serialize_list_precond k /\
i' + Seq.length s' <= Seq.length sx /\
serialize s y == seq_upd_seq sx i' s'
))
(ensures (
let ln1 = Seq.length (serialize (serialize_list _ s) l1) in
let sx = serialize s x in
let sl = serialize (serialize_list _ s) (l1 `L.append` [x]) in
Seq.length sl == ln1 + Seq.length sx /\
ln1 + i' + Seq.length s' <= Seq.length sl /\
serialize (serialize_list _ s) (l1 `L.append` [y]) == seq_upd_seq sl (ln1 + i') s'
))
= serialize_list_upd_chain s l1 x [] y i' s'
#pop-options | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Classical",
"short_module": "Classical"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"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
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: LowParse.Spec.Base.parser k t -> b: LowParse.Bytes.bytes
-> FStar.Pervasives.Lemma
(requires
Mkparser_kind'?.parser_kind_high k ==
FStar.Pervasives.Native.Some (Mkparser_kind'?.parser_kind_low k) /\
Some? (LowParse.Spec.Base.parse (LowParse.Spec.List.parse_list p) b))
(ensures
(let pb = LowParse.Spec.Base.parse (LowParse.Spec.List.parse_list p) b in
Some? pb /\
(let _ = pb in
(let FStar.Pervasives.Native.Some #_ (FStar.Pervasives.Native.Mktuple2 #_ #_ l _) = _ in
FStar.List.Tot.Base.length l * Mkparser_kind'?.parser_kind_low k ==
FStar.Seq.Base.length b)
<:
Prims.logical)))
(decreases FStar.Seq.Base.length b) | FStar.Pervasives.Lemma | [
"lemma",
""
]
| []
| [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Bytes.bytes",
"Prims.op_Equality",
"Prims.int",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.bool",
"LowParse.Spec.Base.consumed_length",
"Prims.list",
"FStar.Math.Lemmas.distributivity_add_left",
"FStar.List.Tot.Base.length",
"Prims.unit",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.parse",
"LowParse.Spec.List.parse_list",
"LowParse.Spec.List.list_length_constant_size_parser_correct",
"FStar.Seq.Base.slice",
"Prims._assert",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.eq2",
"Prims.nat",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"LowParse.Spec.Base.parser_kind_prop_equiv"
]
| [
"recursion"
]
| false | false | true | false | false | let rec list_length_constant_size_parser_correct #k #t p b =
| parser_kind_prop_equiv k p;
let n = k.parser_kind_low in
if Seq.length b = 0
then ()
else
let Some (_, consumed) = parse p b in
assert ((consumed <: nat) == n);
assert (n > 0);
let b':bytes = Seq.slice b n (Seq.length b) in
list_length_constant_size_parser_correct p b';
let Some (l', _) = parse (parse_list p) b' in
FStar.Math.Lemmas.distributivity_add_left 1 (L.length l') n | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.max_output | val max_output : a: Spec.Blake2.Definitions.alg -> Prims.int | let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 44,
"start_col": 22,
"start_line": 41
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Prims.int | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Prims.int"
]
| []
| false | false | false | true | false | let max_output (a: alg) =
| match a with
| Blake2S -> 32
| Blake2B -> 64 | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.size_ivTable | val size_ivTable:size_nat | val size_ivTable:size_nat | let size_ivTable : size_nat = 8 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 53,
"end_line": 34,
"start_col": 22,
"start_line": 34
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
]
| []
| []
| []
| false | false | false | false | false | let size_ivTable:size_nat =
| 8 | false |
LowParse.Spec.List.fst | LowParse.Spec.List.parse_list_bare_injective | val parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p))) | val parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p))) | let parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p)))
= parser_kind_prop_equiv k p;
let f () : Lemma
(injective p)
= ()
in
let rec aux
(b1: bytes)
(b2: bytes)
: Lemma
(requires (injective_precond (parse_list_bare p) b1 b2))
(ensures (injective_postcond (parse_list_bare p) b1 b2))
(decreases (Seq.length b1 + Seq.length b2))
= if Seq.length b1 = 0
then begin
() // assert (Seq.equal b1 b2)
end else begin
assert (injective_precond p b1 b2);
f ();
assert (injective_postcond p b1 b2);
let (Some (_, len1)) = parse p b1 in
let (Some (_, len2)) = parse p b2 in
assert ((len1 <: nat) == (len2 <: nat));
let b1' : bytes = Seq.slice b1 len1 (Seq.length b1) in
let b2' : bytes = Seq.slice b2 len2 (Seq.length b2) in
aux b1' b2';
let (Some (_, len1')) = parse (parse_list_bare p) b1' in
let (Some (_, len2')) = parse (parse_list_bare p) b2' in
Seq.lemma_split (Seq.slice b1 0 (len1 + len1')) len1;
Seq.lemma_split (Seq.slice b2 0 (len2 + len2')) len2;
assert (injective_postcond (parse_list_bare p) b1 b2)
end
in
Classical.forall_intro_2 (fun b -> Classical.move_requires (aux b)) | {
"file_name": "src/lowparse/LowParse.Spec.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 69,
"end_line": 51,
"start_col": 0,
"start_line": 13
} | module LowParse.Spec.List
include LowParse.Spec.Combinators // for seq_slice_append_l
module Seq = FStar.Seq
module L = FStar.List.Tot
module U32 = FStar.UInt32
module Classical = FStar.Classical
(* Parse a list, until there is nothing left to read. This parser will mostly fail EXCEPT if the whole size is known and the slice has been suitably truncated beforehand, or if the elements of the list all have a known constant size. *)
#push-options "--z3rlimit 16" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Classical",
"short_module": "Classical"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"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
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 16,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | p: LowParse.Spec.Base.parser k t
-> FStar.Pervasives.Lemma
(ensures LowParse.Spec.Base.injective (LowParse.Spec.List.parse_list_bare p)) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"FStar.Classical.forall_intro_2",
"LowParse.Bytes.bytes",
"Prims.l_imp",
"LowParse.Spec.Base.injective_precond",
"Prims.list",
"LowParse.Spec.List.parse_list_bare",
"LowParse.Spec.Base.injective_postcond",
"FStar.Classical.move_requires",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"Prims.op_Addition",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"LowParse.Spec.Base.consumed_length",
"Prims._assert",
"FStar.Seq.Properties.lemma_split",
"FStar.Seq.Base.slice",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.parse",
"Prims.eq2",
"Prims.nat",
"LowParse.Spec.Base.injective",
"LowParse.Spec.Base.parser_kind_prop_equiv"
]
| []
| false | false | true | false | false | let parse_list_bare_injective (#k: parser_kind) (#t: Type) (p: parser k t)
: Lemma (ensures (injective (parse_list_bare p))) =
| parser_kind_prop_equiv k p;
let f () : Lemma (injective p) = () in
let rec aux (b1 b2: bytes)
: Lemma (requires (injective_precond (parse_list_bare p) b1 b2))
(ensures (injective_postcond (parse_list_bare p) b1 b2))
(decreases (Seq.length b1 + Seq.length b2)) =
if Seq.length b1 = 0
then ()
else
(assert (injective_precond p b1 b2);
f ();
assert (injective_postcond p b1 b2);
let Some (_, len1) = parse p b1 in
let Some (_, len2) = parse p b2 in
assert ((len1 <: nat) == (len2 <: nat));
let b1':bytes = Seq.slice b1 len1 (Seq.length b1) in
let b2':bytes = Seq.slice b2 len2 (Seq.length b2) in
aux b1' b2';
let Some (_, len1') = parse (parse_list_bare p) b1' in
let Some (_, len2') = parse (parse_list_bare p) b2' in
Seq.lemma_split (Seq.slice b1 0 (len1 + len1')) len1;
Seq.lemma_split (Seq.slice b2 0 (len2 + len2')) len2;
assert (injective_postcond (parse_list_bare p) b1 b2))
in
Classical.forall_intro_2 (fun b -> Classical.move_requires (aux b)) | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.max_key | val max_key : a: Spec.Blake2.Definitions.alg -> Prims.int | let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 40,
"start_col": 22,
"start_line": 37
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Prims.int | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Prims.int"
]
| []
| false | false | false | true | false | let max_key (a: alg) =
| match a with
| Blake2S -> 32
| Blake2B -> 64 | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.size_block | val size_block (a: alg) : size_nat | val size_block (a: alg) : size_nat | let size_block (a:alg) : size_nat = size_block_w * (size_word a) | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 86,
"end_line": 33,
"start_col": 22,
"start_line": 33
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"FStar.Mul.op_Star",
"Spec.Blake2.Definitions.size_block_w",
"Spec.Blake2.Definitions.size_word",
"Lib.IntTypes.size_nat"
]
| []
| false | false | false | true | false | let size_block (a: alg) : size_nat =
| size_block_w * (size_word a) | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.size_sigmaTable | val size_sigmaTable:size_nat | val size_sigmaTable:size_nat | let size_sigmaTable : size_nat = 160 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 58,
"end_line": 35,
"start_col": 22,
"start_line": 35
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | n: Prims.nat{n <= Prims.pow2 32 - 1} | Prims.Tot | [
"total"
]
| []
| []
| []
| false | false | false | false | false | let size_sigmaTable:size_nat =
| 160 | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.max_limb | val max_limb : a: Spec.Blake2.Definitions.alg -> Prims.int | let max_limb (a:alg) = maxint (limb_inttype a) | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 46,
"end_line": 223,
"start_col": 0,
"start_line": 223
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
}
let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
}
inline_for_extraction
let blake2_default_params (a: alg) : blake2_params a =
match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params
inline_for_extraction
type pub_word_t (a:alg) = uint_t (wt a) PUB
inline_for_extraction
type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Prims.int | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.IntTypes.maxint",
"Spec.Blake2.Definitions.limb_inttype",
"Prims.int"
]
| []
| false | false | false | true | false | let max_limb (a: alg) =
| maxint (limb_inttype a) | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.row_idx | val row_idx : Type0 | let row_idx = n:nat {n < 4} | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 261,
"start_col": 0,
"start_line": 261
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
}
let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
}
inline_for_extraction
let blake2_default_params (a: alg) : blake2_params a =
match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params
inline_for_extraction
type pub_word_t (a:alg) = uint_t (wt a) PUB
inline_for_extraction
type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC
inline_for_extraction
let max_limb (a:alg) = maxint (limb_inttype a)
inline_for_extraction
let nat_to_word (a:alg) (x:size_nat) : word_t a =
match (wt a) with
| U32 -> u32 x
| U64 -> u64 x
inline_for_extraction
let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} =
match (wt a) with
| U32 -> u64 x
| U64 -> let h = u64 (x / pow2 64) in
let l = u64 (x % pow2 64) in
(to_u128 h <<. 64ul) +! to_u128 l
inline_for_extraction
let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} =
match (wt a) with
| U32 -> to_u64 x
| U64 -> to_u128 x
inline_for_extraction
let limb_to_word (a:alg) (x:limb_t a) : word_t a =
match (wt a) with
| U32 -> to_u32 x
| U64 -> to_u64 x
unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4
type sigma_elt_t = n:size_t{size_v n < 16}
type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160}
(* Algorithms types *)
type block_s (a:alg) = lseq uint8 (size_block a)
type block_w (a:alg) = lseq (word_t a) 16
type idx_t = n:size_nat{n < 16} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | Type0 | Prims.Tot | [
"total"
]
| []
| [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan"
]
| []
| false | false | false | true | true | let row_idx =
| n: nat{n < 4} | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.limb_inttype | val limb_inttype : a: Spec.Blake2.Definitions.alg -> Lib.IntTypes.inttype | let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 52,
"start_col": 7,
"start_line": 49
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Lib.IntTypes.inttype | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.U64",
"Lib.IntTypes.U128",
"Lib.IntTypes.inttype"
]
| []
| false | false | false | true | false | let limb_inttype (a: alg) =
| match (wt a) with
| U32 -> U64
| U64 -> U128 | false |
|
LowParse.Spec.List.fst | LowParse.Spec.List.bare_serialize_list_correct | val bare_serialize_list_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (serialize_list_precond k))
(ensures (serializer_correct (parse_list p) (bare_serialize_list p s))) | val bare_serialize_list_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (serialize_list_precond k))
(ensures (serializer_correct (parse_list p) (bare_serialize_list p s))) | let bare_serialize_list_correct
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(s: serializer p)
: Lemma
(requires (serialize_list_precond k))
(ensures (serializer_correct (parse_list p) (bare_serialize_list p s)))
= parser_kind_prop_equiv k p;
let f () : Lemma (serialize_list_precond k) = () in
let rec prf
(l: list t)
: Lemma
(parse (parse_list p) (bare_serialize_list p s l) == Some (l, Seq.length (bare_serialize_list p s l)))
= match l with
| [] -> ()
| a :: q ->
let pa = parse p (bare_serialize_list p s l) in
f ();
parser_kind_prop_equiv k p;
assert (no_lookahead_on p (serialize s a) (bare_serialize_list p s l));
seq_slice_append_l (serialize s a) (bare_serialize_list p s q);
assert (no_lookahead_on_precond p (serialize s a) (bare_serialize_list p s l));
assert (no_lookahead_on_postcond p (serialize s a) (bare_serialize_list p s l));
assert (Some? pa);
assert (injective_precond p (serialize s a) (bare_serialize_list p s l));
assert (injective_postcond p (serialize s a) (bare_serialize_list p s l));
let (Some (a', lena)) = pa in
assert (a == a');
assert (lena == Seq.length (serialize s a));
assert (lena > 0);
prf q;
seq_slice_append_r (serialize s a) (bare_serialize_list p s q)
in
Classical.forall_intro prf | {
"file_name": "src/lowparse/LowParse.Spec.List.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 28,
"end_line": 167,
"start_col": 0,
"start_line": 133
} | module LowParse.Spec.List
include LowParse.Spec.Combinators // for seq_slice_append_l
module Seq = FStar.Seq
module L = FStar.List.Tot
module U32 = FStar.UInt32
module Classical = FStar.Classical
(* Parse a list, until there is nothing left to read. This parser will mostly fail EXCEPT if the whole size is known and the slice has been suitably truncated beforehand, or if the elements of the list all have a known constant size. *)
#push-options "--z3rlimit 16"
let parse_list_bare_injective
(#k: parser_kind)
(#t: Type)
(p: parser k t)
: Lemma
(ensures (injective (parse_list_bare p)))
= parser_kind_prop_equiv k p;
let f () : Lemma
(injective p)
= ()
in
let rec aux
(b1: bytes)
(b2: bytes)
: Lemma
(requires (injective_precond (parse_list_bare p) b1 b2))
(ensures (injective_postcond (parse_list_bare p) b1 b2))
(decreases (Seq.length b1 + Seq.length b2))
= if Seq.length b1 = 0
then begin
() // assert (Seq.equal b1 b2)
end else begin
assert (injective_precond p b1 b2);
f ();
assert (injective_postcond p b1 b2);
let (Some (_, len1)) = parse p b1 in
let (Some (_, len2)) = parse p b2 in
assert ((len1 <: nat) == (len2 <: nat));
let b1' : bytes = Seq.slice b1 len1 (Seq.length b1) in
let b2' : bytes = Seq.slice b2 len2 (Seq.length b2) in
aux b1' b2';
let (Some (_, len1')) = parse (parse_list_bare p) b1' in
let (Some (_, len2')) = parse (parse_list_bare p) b2' in
Seq.lemma_split (Seq.slice b1 0 (len1 + len1')) len1;
Seq.lemma_split (Seq.slice b2 0 (len2 + len2')) len2;
assert (injective_postcond (parse_list_bare p) b1 b2)
end
in
Classical.forall_intro_2 (fun b -> Classical.move_requires (aux b))
#pop-options
let parse_list #k #t p =
parse_list_bare_injective p;
parse_list_bare_consumes_all p;
parser_kind_prop_equiv parse_list_kind (parse_list_bare p);
parse_list_bare p
let parse_list_eq
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
))
= ()
let parse_list_eq'
(#k: parser_kind)
(#t: Type)
(p: parser k t)
(b: bytes)
: Lemma
(requires (k.parser_kind_low > 0))
(ensures (parse (parse_list p) b == (
if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match parse p b with
| None -> None
| Some (v, n) ->
begin match parse (parse_list p) (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
end
)))
= ()
let rec tot_parse_list_aux
(#k: parser_kind)
(#t: Type)
(p: tot_parser k t)
(b: bytes)
: Pure (option (list t * (consumed_length b)))
(requires True)
(ensures (fun y -> y == parse_list_aux #k p b))
(decreases (Seq.length b))
= if Seq.length b = 0
then
Some ([], (0 <: consumed_length b))
else
match p b with
| None -> None
| Some (v, n) ->
if n = 0
then None (* elements cannot be empty *)
else
match tot_parse_list_aux p (Seq.slice b n (Seq.length b)) with
| Some (l, n') -> Some (v :: l, (n + n' <: consumed_length b))
| _ -> None
let tot_parse_list #k #t p =
parser_kind_prop_ext parse_list_kind (parse_list #k p) (tot_parse_list_aux p);
tot_parse_list_aux p | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.Combinators.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.List.Tot.fst.checked",
"FStar.Classical.fsti.checked"
],
"interface_file": true,
"source_file": "LowParse.Spec.List.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Classical",
"short_module": "Classical"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": false,
"full_module": "LowParse.Spec.Combinators",
"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
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: LowParse.Spec.Base.parser k t -> s: LowParse.Spec.Base.serializer p
-> FStar.Pervasives.Lemma (requires LowParse.Spec.List.serialize_list_precond k)
(ensures
LowParse.Spec.Base.serializer_correct (LowParse.Spec.List.parse_list p)
(LowParse.Spec.List.bare_serialize_list p s)) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"LowParse.Spec.Base.parser_kind",
"LowParse.Spec.Base.parser",
"LowParse.Spec.Base.serializer",
"FStar.Classical.forall_intro",
"Prims.list",
"Prims.eq2",
"FStar.Pervasives.Native.option",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.Base.consumed_length",
"LowParse.Spec.List.bare_serialize_list",
"LowParse.Spec.Base.parse",
"LowParse.Spec.List.parse_list",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Seq.Base.length",
"LowParse.Bytes.byte",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"LowParse.Spec.Combinators.seq_slice_append_r",
"LowParse.Spec.Base.serialize",
"Prims._assert",
"Prims.b2t",
"Prims.op_GreaterThan",
"Prims.nat",
"LowParse.Spec.Base.injective_postcond",
"LowParse.Spec.Base.injective_precond",
"FStar.Pervasives.Native.uu___is_Some",
"LowParse.Spec.Base.no_lookahead_on_postcond",
"LowParse.Spec.Base.no_lookahead_on_precond",
"LowParse.Spec.Combinators.seq_slice_append_l",
"LowParse.Spec.Base.no_lookahead_on",
"LowParse.Spec.Base.parser_kind_prop_equiv",
"Prims.op_AmpAmp",
"Prims.op_Equality",
"LowParse.Spec.Base.parser_subkind",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_subkind",
"LowParse.Spec.Base.ParserStrong",
"LowParse.Spec.Base.__proj__Mkparser_kind'__item__parser_kind_low",
"LowParse.Spec.List.serialize_list_precond",
"LowParse.Spec.Base.serializer_correct",
"LowParse.Spec.List.parse_list_kind"
]
| []
| false | false | true | false | false | let bare_serialize_list_correct (#k: parser_kind) (#t: Type) (p: parser k t) (s: serializer p)
: Lemma (requires (serialize_list_precond k))
(ensures (serializer_correct (parse_list p) (bare_serialize_list p s))) =
| parser_kind_prop_equiv k p;
let f () : Lemma (serialize_list_precond k) = () in
let rec prf (l: list t)
: Lemma
(parse (parse_list p) (bare_serialize_list p s l) ==
Some (l, Seq.length (bare_serialize_list p s l))) =
match l with
| [] -> ()
| a :: q ->
let pa = parse p (bare_serialize_list p s l) in
f ();
parser_kind_prop_equiv k p;
assert (no_lookahead_on p (serialize s a) (bare_serialize_list p s l));
seq_slice_append_l (serialize s a) (bare_serialize_list p s q);
assert (no_lookahead_on_precond p (serialize s a) (bare_serialize_list p s l));
assert (no_lookahead_on_postcond p (serialize s a) (bare_serialize_list p s l));
assert (Some? pa);
assert (injective_precond p (serialize s a) (bare_serialize_list p s l));
assert (injective_postcond p (serialize s a) (bare_serialize_list p s l));
let Some (a', lena) = pa in
assert (a == a');
assert (lena == Seq.length (serialize s a));
assert (lena > 0);
prf q;
seq_slice_append_r (serialize s a) (bare_serialize_list p s q)
in
Classical.forall_intro prf | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.personal_length | val personal_length (a: alg) : size_nat | val personal_length (a: alg) : size_nat | let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 90,
"start_col": 0,
"start_line": 87
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.IntTypes.size_nat"
]
| []
| false | false | false | true | false | let personal_length (a: alg) : size_nat =
| match a with
| Blake2S -> 8
| Blake2B -> 16 | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.state | val state : a: Spec.Blake2.Definitions.alg -> Type0 | let state (a:alg) = lseq (row a) 4 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 78,
"start_col": 7,
"start_line": 78
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Type0 | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.Sequence.lseq",
"Spec.Blake2.Definitions.row"
]
| []
| false | false | false | true | true | let state (a: alg) =
| lseq (row a) 4 | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.salt_length | val salt_length (a: alg) : size_nat | val salt_length (a: alg) : size_nat | let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 17,
"end_line": 84,
"start_col": 0,
"start_line": 81
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Lib.IntTypes.size_nat | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.IntTypes.size_nat"
]
| []
| false | false | false | true | false | let salt_length (a: alg) : size_nat =
| match a with
| Blake2S -> 8
| Blake2B -> 16 | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.zero | val zero (a: alg) : word_t a | val zero (a: alg) : word_t a | let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 61,
"start_col": 0,
"start_line": 58
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Spec.Blake2.Definitions.word_t a | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.IntTypes.u32",
"Lib.IntTypes.u64",
"Spec.Blake2.Definitions.word_t"
]
| []
| false | false | false | false | false | let zero (a: alg) : word_t a =
| match a with
| Blake2S -> u32 0
| Blake2B -> u64 0 | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.zero_row | val zero_row (a: alg) : row a | val zero_row (a: alg) : row a | let zero_row (a:alg) : row a = create 4 (zero a) | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 67,
"start_col": 0,
"start_line": 67
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Spec.Blake2.Definitions.row a | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.Sequence.create",
"Spec.Blake2.Definitions.word_t",
"Spec.Blake2.Definitions.zero",
"Spec.Blake2.Definitions.row"
]
| []
| false | false | false | false | false | let zero_row (a: alg) : row a =
| create 4 (zero a) | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.set_blake2s_key_length | val set_blake2s_key_length (p: blake2s_params) (kk: size_nat{kk <= max_key Blake2S})
: blake2s_params | val set_blake2s_key_length (p: blake2s_params) (kk: size_nat{kk <= max_key Blake2S})
: blake2s_params | let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk} | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 121,
"start_col": 0,
"start_line": 117
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
p: Spec.Blake2.Definitions.blake2s_params ->
kk: Lib.IntTypes.size_nat{kk <= Spec.Blake2.Definitions.max_key Spec.Blake2.Definitions.Blake2S}
-> Spec.Blake2.Definitions.blake2s_params | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.blake2s_params",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.Blake2.Definitions.max_key",
"Spec.Blake2.Definitions.Blake2S",
"Spec.Blake2.Definitions.Mkblake2s_params",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__digest_length",
"Lib.IntTypes.u8",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__fanout",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__depth",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__leaf_length",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__node_offset",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__xof_length",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__node_depth",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__inner_length",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__salt",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__personal"
]
| []
| false | false | false | false | false | let set_blake2s_key_length (p: blake2s_params) (kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
| { p with key_length = u8 kk } | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.get_salt | val get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) | val get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) | let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 21,
"end_line": 174,
"start_col": 0,
"start_line": 171
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: Spec.Blake2.Definitions.blake2_params a
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (Spec.Blake2.Definitions.salt_length a) | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.blake2_params",
"Spec.Blake2.Definitions.get_blake2s_salt",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__salt",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Spec.Blake2.Definitions.salt_length"
]
| []
| false | false | false | false | false | let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
| match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.get_personal | val get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) | val get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) | let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 25,
"end_line": 180,
"start_col": 0,
"start_line": 177
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: Spec.Blake2.Definitions.blake2_params a
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (Spec.Blake2.Definitions.personal_length a) | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.blake2_params",
"Spec.Blake2.Definitions.get_blake2s_personal",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__personal",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Spec.Blake2.Definitions.personal_length"
]
| []
| false | false | false | false | false | let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
| match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.set_blake2s_digest_length | val set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params | val set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params | let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn} | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 114,
"start_col": 0,
"start_line": 110
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
p: Spec.Blake2.Definitions.blake2s_params ->
nn:
Lib.IntTypes.size_nat
{1 <= nn /\ nn <= Spec.Blake2.Definitions.max_output Spec.Blake2.Definitions.Blake2S}
-> Spec.Blake2.Definitions.blake2s_params | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.blake2s_params",
"Lib.IntTypes.size_nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.Blake2.Definitions.max_output",
"Spec.Blake2.Definitions.Blake2S",
"Spec.Blake2.Definitions.Mkblake2s_params",
"Lib.IntTypes.u8",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__key_length",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__fanout",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__depth",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__leaf_length",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__node_offset",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__xof_length",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__node_depth",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__inner_length",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__salt",
"Spec.Blake2.Definitions.__proj__Mkblake2s_params__item__personal"
]
| []
| false | false | false | false | false | let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
| { p with digest_length = u8 nn } | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.blake2_params | val blake2_params : a: Spec.Blake2.Definitions.alg -> Type0 | let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 29,
"end_line": 150,
"start_col": 0,
"start_line": 147
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Type0 | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.blake2s_params",
"Spec.Blake2.Definitions.blake2b_params"
]
| []
| false | false | false | true | true | let blake2_params (a: alg) =
| match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.row | val row : a: Spec.Blake2.Definitions.alg -> Type0 | let row (a:alg) = lseq (word_t a) 4 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 64,
"start_col": 7,
"start_line": 64
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Type0 | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.Sequence.lseq",
"Spec.Blake2.Definitions.word_t"
]
| []
| false | false | false | true | true | let row (a: alg) =
| lseq (word_t a) 4 | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.set_digest_length | val set_digest_length (#a: alg) (p: blake2_params a) (nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a | val set_digest_length (#a: alg) (p: blake2_params a) (nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a | let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn} | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 45,
"end_line": 159,
"start_col": 0,
"start_line": 153
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
p: Spec.Blake2.Definitions.blake2_params a ->
nn: Lib.IntTypes.size_nat{1 <= nn /\ nn <= Spec.Blake2.Definitions.max_output a}
-> Spec.Blake2.Definitions.blake2_params a | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.blake2_params",
"Lib.IntTypes.size_nat",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.Blake2.Definitions.max_output",
"Spec.Blake2.Definitions.set_blake2s_digest_length",
"Spec.Blake2.Definitions.Mkblake2b_params",
"Lib.IntTypes.u8",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__key_length",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__fanout",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__depth",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__leaf_length",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__node_offset",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__xof_length",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__node_depth",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__inner_length",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__salt",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__personal"
]
| []
| false | false | false | false | false | let set_digest_length (#a: alg) (p: blake2_params a) (nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
| match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> { p with digest_length = u8 nn } | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.blake2_default_params | val blake2_default_params (a: alg) : blake2_params a | val blake2_default_params (a: alg) : blake2_params a | let blake2_default_params (a: alg) : blake2_params a =
match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 37,
"end_line": 214,
"start_col": 0,
"start_line": 211
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
}
let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Spec.Blake2.Definitions.blake2_params a | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.blake2s_default_params",
"Spec.Blake2.Definitions.blake2b_default_params",
"Spec.Blake2.Definitions.blake2_params"
]
| []
| false | false | false | false | false | let blake2_default_params (a: alg) : blake2_params a =
| match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.limb_to_word | val limb_to_word (a: alg) (x: limb_t a) : word_t a | val limb_to_word (a: alg) (x: limb_t a) : word_t a | let limb_to_word (a:alg) (x:limb_t a) : word_t a =
match (wt a) with
| U32 -> to_u32 x
| U64 -> to_u64 x | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 19,
"end_line": 249,
"start_col": 0,
"start_line": 246
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
}
let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
}
inline_for_extraction
let blake2_default_params (a: alg) : blake2_params a =
match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params
inline_for_extraction
type pub_word_t (a:alg) = uint_t (wt a) PUB
inline_for_extraction
type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC
inline_for_extraction
let max_limb (a:alg) = maxint (limb_inttype a)
inline_for_extraction
let nat_to_word (a:alg) (x:size_nat) : word_t a =
match (wt a) with
| U32 -> u32 x
| U64 -> u64 x
inline_for_extraction
let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} =
match (wt a) with
| U32 -> u64 x
| U64 -> let h = u64 (x / pow2 64) in
let l = u64 (x % pow2 64) in
(to_u128 h <<. 64ul) +! to_u128 l
inline_for_extraction
let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} =
match (wt a) with
| U32 -> to_u64 x
| U64 -> to_u128 x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> x: Spec.Blake2.Definitions.limb_t a
-> Spec.Blake2.Definitions.word_t a | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.limb_t",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.to_u32",
"Spec.Blake2.Definitions.limb_inttype",
"Lib.IntTypes.SEC",
"Lib.IntTypes.to_u64",
"Spec.Blake2.Definitions.word_t"
]
| []
| false | false | false | false | false | let limb_to_word (a: alg) (x: limb_t a) : word_t a =
| match (wt a) with
| U32 -> to_u32 x
| U64 -> to_u64 x | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.blake2b_default_params | val blake2b_default_params:blake2b_params | val blake2b_default_params:blake2b_params | let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
} | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 208,
"start_col": 0,
"start_line": 196
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | Spec.Blake2.Definitions.blake2b_params | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.Mkblake2b_params",
"Lib.IntTypes.u8",
"Lib.IntTypes.u32",
"Lib.Sequence.create",
"Lib.IntTypes.uint8"
]
| []
| false | false | false | true | false | let blake2b_default_params:blake2b_params =
| {
digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0)
} | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.set_key_length | val set_key_length (#a: alg) (p: blake2_params a) (kk: size_nat{kk <= max_key a}) : blake2_params a | val set_key_length (#a: alg) (p: blake2_params a) (kk: size_nat{kk <= max_key a}) : blake2_params a | let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk} | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 42,
"end_line": 168,
"start_col": 0,
"start_line": 162
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
p: Spec.Blake2.Definitions.blake2_params a ->
kk: Lib.IntTypes.size_nat{kk <= Spec.Blake2.Definitions.max_key a}
-> Spec.Blake2.Definitions.blake2_params a | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.blake2_params",
"Lib.IntTypes.size_nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.Blake2.Definitions.max_key",
"Spec.Blake2.Definitions.set_blake2s_key_length",
"Spec.Blake2.Definitions.Mkblake2b_params",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__digest_length",
"Lib.IntTypes.u8",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__fanout",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__depth",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__leaf_length",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__node_offset",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__xof_length",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__node_depth",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__inner_length",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__salt",
"Spec.Blake2.Definitions.__proj__Mkblake2b_params__item__personal"
]
| []
| false | false | false | false | false | let set_key_length (#a: alg) (p: blake2_params a) (kk: size_nat{kk <= max_key a}) : blake2_params a =
| match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> { p with key_length = u8 kk } | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.blake2s_default_params | val blake2s_default_params:blake2s_params | val blake2s_default_params:blake2s_params | let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
} | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 194,
"start_col": 0,
"start_line": 182
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | Spec.Blake2.Definitions.blake2s_params | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.Mkblake2s_params",
"Lib.IntTypes.u8",
"Lib.IntTypes.u32",
"Lib.IntTypes.u16",
"Lib.Sequence.create",
"Lib.IntTypes.uint8"
]
| []
| false | false | false | true | false | let blake2s_default_params:blake2s_params =
| {
digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0)
} | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.nat_to_word | val nat_to_word (a: alg) (x: size_nat) : word_t a | val nat_to_word (a: alg) (x: size_nat) : word_t a | let nat_to_word (a:alg) (x:size_nat) : word_t a =
match (wt a) with
| U32 -> u32 x
| U64 -> u64 x | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 229,
"start_col": 0,
"start_line": 226
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
}
let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
}
inline_for_extraction
let blake2_default_params (a: alg) : blake2_params a =
match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params
inline_for_extraction
type pub_word_t (a:alg) = uint_t (wt a) PUB
inline_for_extraction
type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC
inline_for_extraction
let max_limb (a:alg) = maxint (limb_inttype a) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> x: Lib.IntTypes.size_nat -> Spec.Blake2.Definitions.word_t a | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.IntTypes.size_nat",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.u32",
"Lib.IntTypes.u64",
"Spec.Blake2.Definitions.word_t"
]
| []
| false | false | false | false | false | let nat_to_word (a: alg) (x: size_nat) : word_t a =
| match (wt a) with
| U32 -> u32 x
| U64 -> u64 x | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.rtable_t | val rtable_t : a: Spec.Blake2.Definitions.alg -> Type0 | let rtable_t (a:alg) = lseq (rotval (wt a)) 4 | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 251,
"start_col": 7,
"start_line": 251
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
}
let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
}
inline_for_extraction
let blake2_default_params (a: alg) : blake2_params a =
match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params
inline_for_extraction
type pub_word_t (a:alg) = uint_t (wt a) PUB
inline_for_extraction
type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC
inline_for_extraction
let max_limb (a:alg) = maxint (limb_inttype a)
inline_for_extraction
let nat_to_word (a:alg) (x:size_nat) : word_t a =
match (wt a) with
| U32 -> u32 x
| U64 -> u64 x
inline_for_extraction
let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} =
match (wt a) with
| U32 -> u64 x
| U64 -> let h = u64 (x / pow2 64) in
let l = u64 (x % pow2 64) in
(to_u128 h <<. 64ul) +! to_u128 l
inline_for_extraction
let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} =
match (wt a) with
| U32 -> to_u64 x
| U64 -> to_u128 x
inline_for_extraction
let limb_to_word (a:alg) (x:limb_t a) : word_t a =
match (wt a) with
| U32 -> to_u32 x
| U64 -> to_u64 x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> Type0 | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.Sequence.lseq",
"Lib.IntTypes.rotval",
"Spec.Blake2.Definitions.wt"
]
| []
| false | false | false | true | true | let rtable_t (a: alg) =
| lseq (rotval (wt a)) 4 | false |
|
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.word_to_limb | val word_to_limb (a: alg) (x: word_t a {uint_v x <= max_limb a})
: xl: limb_t a {uint_v xl == uint_v x} | val word_to_limb (a: alg) (x: word_t a {uint_v x <= max_limb a})
: xl: limb_t a {uint_v xl == uint_v x} | let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} =
match (wt a) with
| U32 -> to_u64 x
| U64 -> to_u128 x | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 243,
"start_col": 0,
"start_line": 240
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
}
let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
}
inline_for_extraction
let blake2_default_params (a: alg) : blake2_params a =
match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params
inline_for_extraction
type pub_word_t (a:alg) = uint_t (wt a) PUB
inline_for_extraction
type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC
inline_for_extraction
let max_limb (a:alg) = maxint (limb_inttype a)
inline_for_extraction
let nat_to_word (a:alg) (x:size_nat) : word_t a =
match (wt a) with
| U32 -> u32 x
| U64 -> u64 x
inline_for_extraction
let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} =
match (wt a) with
| U32 -> u64 x
| U64 -> let h = u64 (x / pow2 64) in
let l = u64 (x % pow2 64) in
(to_u128 h <<. 64ul) +! to_u128 l | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
a: Spec.Blake2.Definitions.alg ->
x:
Spec.Blake2.Definitions.word_t a {Lib.IntTypes.uint_v x <= Spec.Blake2.Definitions.max_limb a}
-> xl: Spec.Blake2.Definitions.limb_t a {Lib.IntTypes.uint_v xl == Lib.IntTypes.uint_v x} | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.word_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Lib.IntTypes.uint_v",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.SEC",
"Spec.Blake2.Definitions.max_limb",
"Lib.IntTypes.to_u64",
"Lib.IntTypes.to_u128",
"Spec.Blake2.Definitions.limb_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Spec.Blake2.Definitions.limb_inttype"
]
| []
| false | false | false | false | false | let word_to_limb (a: alg) (x: word_t a {uint_v x <= max_limb a})
: xl: limb_t a {uint_v xl == uint_v x} =
| match (wt a) with
| U32 -> to_u64 x
| U64 -> to_u128 x | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.rotr | val rotr (#a: alg) (r1: row a) (r: row_idx) : row a | val rotr (#a: alg) (r1: row a) (r: row_idx) : row a | let rotr (#a:alg) (r1:row a) (r:row_idx) : row a =
createi 4 (fun i -> r1.[(i+r)%4]) | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 277,
"start_col": 0,
"start_line": 276
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
}
let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
}
inline_for_extraction
let blake2_default_params (a: alg) : blake2_params a =
match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params
inline_for_extraction
type pub_word_t (a:alg) = uint_t (wt a) PUB
inline_for_extraction
type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC
inline_for_extraction
let max_limb (a:alg) = maxint (limb_inttype a)
inline_for_extraction
let nat_to_word (a:alg) (x:size_nat) : word_t a =
match (wt a) with
| U32 -> u32 x
| U64 -> u64 x
inline_for_extraction
let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} =
match (wt a) with
| U32 -> u64 x
| U64 -> let h = u64 (x / pow2 64) in
let l = u64 (x % pow2 64) in
(to_u128 h <<. 64ul) +! to_u128 l
inline_for_extraction
let word_to_limb (a:alg) (x:word_t a{uint_v x <= max_limb a}) : xl:limb_t a{uint_v xl == uint_v x} =
match (wt a) with
| U32 -> to_u64 x
| U64 -> to_u128 x
inline_for_extraction
let limb_to_word (a:alg) (x:limb_t a) : word_t a =
match (wt a) with
| U32 -> to_u32 x
| U64 -> to_u64 x
unfold let rtable_t (a:alg) = lseq (rotval (wt a)) 4
type sigma_elt_t = n:size_t{size_v n < 16}
type list_sigma_t = l:list sigma_elt_t{List.Tot.length l == 160}
(* Algorithms types *)
type block_s (a:alg) = lseq uint8 (size_block a)
type block_w (a:alg) = lseq (word_t a) 16
type idx_t = n:size_nat{n < 16}
let row_idx = n:nat {n < 4}
inline_for_extraction
let ( ^| ) (#a:alg) (r1:row a) (r2:row a) : row a =
map2 ( ^. ) r1 r2
inline_for_extraction
let ( +| ) (#a:alg) (r1:row a) (r2:row a) : row a =
map2 ( +. ) r1 r2
inline_for_extraction
let ( >>>| ) (#a:alg) (r1:row a) (r:rotval (wt a)) : row a =
map #(word_t a) (rotate_right_i r) r1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | r1: Spec.Blake2.Definitions.row a -> r: Spec.Blake2.Definitions.row_idx
-> Spec.Blake2.Definitions.row a | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Spec.Blake2.Definitions.row",
"Spec.Blake2.Definitions.row_idx",
"Lib.Sequence.createi",
"Spec.Blake2.Definitions.word_t",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.Sequence.op_String_Access",
"Prims.op_Modulus",
"Prims.op_Addition"
]
| []
| false | false | false | false | false | let rotr (#a: alg) (r1: row a) (r: row_idx) : row a =
| createi 4 (fun i -> r1.[ (i + r) % 4 ]) | false |
Hacl.Impl.Frodo.KEM.Encaps.fst | Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc0 | val crypto_kem_enc0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\ live h seed_se_k /\
loc_pairwise_disjoint [loc mu; loc ct; loc ss; loc pk; loc seed_se_k])
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss |+| loc seed_se_k) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk)) | val crypto_kem_enc0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\ live h seed_se_k /\
loc_pairwise_disjoint [loc mu; loc ct; loc ss; loc pk; loc seed_se_k])
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss |+| loc seed_se_k) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk)) | let crypto_kem_enc0 a gen_a mu ct ss pk seed_se_k =
crypto_kem_enc_seed_se_k a mu pk seed_se_k;
crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk | {
"file_name": "code/frodo/Hacl.Impl.Frodo.KEM.Encaps.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 388,
"start_col": 0,
"start_line": 386
} | module Hacl.Impl.Frodo.KEM.Encaps
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open LowStar.Buffer
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Impl.Frodo.Encode
open Hacl.Impl.Frodo.Pack
open Hacl.Impl.Frodo.Sample
open Hacl.Frodo.Random
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module LB = Lib.ByteSequence
module FP = Spec.Frodo.Params
module S = Spec.Frodo.KEM.Encaps
module M = Spec.Matrix
module KG = Hacl.Impl.Frodo.KEM.KeyGen
#set-options "--z3rlimit 100 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val frodo_mul_add_sa_plus_e:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> bp_matrix:matrix_t params_nbar (params_n a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h bp_matrix /\
disjoint bp_matrix seed_a /\ disjoint bp_matrix ep_matrix /\ disjoint bp_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc bp_matrix) h0 h1 /\
as_matrix h1 bp_matrix ==
S.frodo_mul_add_sa_plus_e a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix =
push_frame ();
let a_matrix = matrix_create (params_n a) (params_n a) in
frodo_gen_matrix gen_a (params_n a) seed_a a_matrix;
matrix_mul sp_matrix a_matrix bp_matrix;
matrix_add bp_matrix ep_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c1:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> c1:lbytes (ct1bytes_len a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h ep_matrix /\ live h sp_matrix /\ live h c1 /\
disjoint seed_a c1 /\ disjoint ep_matrix c1 /\ disjoint sp_matrix c1)
(ensures fun h0 _ h1 -> modifies (loc c1) h0 h1 /\
as_seq h1 c1 ==
S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_matrix h0 sp_matrix) (as_matrix h0 ep_matrix))
let crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1 =
push_frame ();
let bp_matrix = matrix_create params_nbar (params_n a) in
frodo_mul_add_sa_plus_e a gen_a seed_a sp_matrix ep_matrix bp_matrix;
frodo_pack (params_logq a) bp_matrix c1;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e:
a:FP.frodo_alg
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h epp_matrix /\ live h v_matrix /\ live h sp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix epp_matrix /\ disjoint v_matrix sp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e a (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix =
push_frame ();
let b_matrix = matrix_create (params_n a) params_nbar in
frodo_unpack (params_n a) params_nbar (params_logq a) b b_matrix;
matrix_mul sp_matrix b_matrix v_matrix;
matrix_add v_matrix epp_matrix;
pop_frame ()
inline_for_extraction noextract
val frodo_mul_add_sb_plus_e_plus_mu:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> v_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h b /\ live h mu /\ live h v_matrix /\
live h sp_matrix /\ live h epp_matrix /\
disjoint v_matrix b /\ disjoint v_matrix sp_matrix /\
disjoint v_matrix mu /\ disjoint v_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc v_matrix) h0 h1 /\
as_matrix h1 v_matrix ==
S.frodo_mul_add_sb_plus_e_plus_mu a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
let frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix =
push_frame ();
frodo_mul_add_sb_plus_e a b sp_matrix epp_matrix v_matrix;
let mu_encode = matrix_create params_nbar params_nbar in
frodo_key_encode (params_logq a) (params_extracted_bits a) params_nbar mu mu_encode;
matrix_add v_matrix mu_encode;
clear_matrix mu_encode;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_pack_c2:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> b:lbytes (publicmatrixbytes_len a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> c2:lbytes (ct2bytes_len a)
-> Stack unit
(requires fun h ->
live h mu /\ live h b /\ live h sp_matrix /\
live h epp_matrix /\ live h c2 /\
disjoint mu c2 /\ disjoint b c2 /\
disjoint sp_matrix c2 /\ disjoint epp_matrix c2)
(ensures fun h0 _ h1 -> modifies (loc c2) h0 h1 /\
as_seq h1 c2 ==
S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_matrix h0 sp_matrix) (as_matrix h0 epp_matrix))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2 =
push_frame ();
let v_matrix = matrix_create params_nbar params_nbar in
frodo_mul_add_sb_plus_e_plus_mu a mu b sp_matrix epp_matrix v_matrix;
frodo_pack (params_logq a) v_matrix c2;
clear_matrix v_matrix;
pop_frame ()
#pop-options
inline_for_extraction noextract
val get_sp_ep_epp_matrices:
a:FP.frodo_alg
-> seed_se:lbytes (crypto_bytes a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h seed_se /\ live h sp_matrix /\
live h ep_matrix /\ live h epp_matrix /\
disjoint seed_se sp_matrix /\ disjoint seed_se ep_matrix /\
disjoint seed_se epp_matrix /\ disjoint sp_matrix ep_matrix /\
disjoint sp_matrix epp_matrix /\ disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1 /\
(as_matrix h1 sp_matrix, as_matrix h1 ep_matrix, as_matrix h1 epp_matrix) ==
S.get_sp_ep_epp_matrices a (as_seq h0 seed_se))
let get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix =
push_frame ();
[@inline_let] let s_bytes_len = secretmatrixbytes_len a in
let r = create (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) (u8 0) in
KG.frodo_shake_r a (u8 0x96) seed_se (2ul *! s_bytes_len +! 2ul *! params_nbar *! params_nbar) r;
frodo_sample_matrix a params_nbar (params_n a) (sub r 0ul s_bytes_len) sp_matrix;
frodo_sample_matrix a params_nbar (params_n a) (sub r s_bytes_len s_bytes_len) ep_matrix;
frodo_sample_matrix a params_nbar params_nbar (sub r (2ul *! s_bytes_len) (2ul *! params_nbar *! params_nbar)) epp_matrix;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_a:lbytes bytes_seed_a
-> b:lbytes (publicmatrixbytes_len a)
-> mu:lbytes (bytes_mu a)
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h seed_a /\ live h b /\ live h mu /\ live h ct /\
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint ct seed_a /\ disjoint ct b /\ disjoint ct mu /\
disjoint ct sp_matrix /\ disjoint ct ep_matrix /\ disjoint ct epp_matrix)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
(let c1:LB.lbytes (FP.ct1bytes_len a) = S.crypto_kem_enc_ct_pack_c1 a gen_a (as_seq h0 seed_a) (as_seq h0 sp_matrix) (as_seq h0 ep_matrix) in
let c2:LB.lbytes (FP.ct2bytes_len a) = S.crypto_kem_enc_ct_pack_c2 a (as_seq h0 mu) (as_seq h0 b) (as_seq h0 sp_matrix) (as_seq h0 epp_matrix) in
v (crypto_ciphertextbytes a) == FP.ct1bytes_len a + FP.ct2bytes_len a /\
as_seq h1 ct `Seq.equal` LSeq.concat #_ #(FP.ct1bytes_len a) #(FP.ct2bytes_len a) c1 c2))
let crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct =
let c1 = sub ct 0ul (ct1bytes_len a) in
let c2 = sub ct (ct1bytes_len a) (ct2bytes_len a) in
let h0 = ST.get () in
crypto_kem_enc_ct_pack_c1 a gen_a seed_a sp_matrix ep_matrix c1;
let h1 = ST.get () in
crypto_kem_enc_ct_pack_c2 a mu b sp_matrix epp_matrix c2;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 ct) 0 (v (ct1bytes_len a)))
(LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)));
LSeq.lemma_concat2
(v (ct1bytes_len a)) (LSeq.sub (as_seq h1 ct) 0 (v (ct1bytes_len a)))
(v (ct2bytes_len a)) (LSeq.sub (as_seq h2 ct) (v (ct1bytes_len a)) (v (ct2bytes_len a))) (as_seq h2 ct)
inline_for_extraction noextract
val clear_matrix3:
a:FP.frodo_alg
-> sp_matrix:matrix_t params_nbar (params_n a)
-> ep_matrix:matrix_t params_nbar (params_n a)
-> epp_matrix:matrix_t params_nbar params_nbar
-> Stack unit
(requires fun h ->
live h sp_matrix /\ live h ep_matrix /\ live h epp_matrix /\
disjoint sp_matrix ep_matrix /\ disjoint sp_matrix epp_matrix /\
disjoint ep_matrix epp_matrix)
(ensures fun h0 _ h1 ->
modifies (loc sp_matrix |+| loc ep_matrix |+| loc epp_matrix) h0 h1)
let clear_matrix3 a sp_matrix ep_matrix epp_matrix =
clear_matrix sp_matrix;
clear_matrix ep_matrix;
clear_matrix epp_matrix
inline_for_extraction noextract
val crypto_kem_enc_ct:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se /\ live h ct /\
disjoint ct mu /\ disjoint ct pk /\ disjoint ct seed_se)
(ensures fun h0 _ h1 -> modifies (loc ct) h0 h1 /\
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se))
#push-options "--z3rlimit 200"
let crypto_kem_enc_ct a gen_a mu pk seed_se ct =
push_frame ();
let h0 = ST.get () in
FP.expand_crypto_publickeybytes a;
let seed_a = sub pk 0ul bytes_seed_a in
let b = sub pk bytes_seed_a (publicmatrixbytes_len a) in
let sp_matrix = matrix_create params_nbar (params_n a) in
let ep_matrix = matrix_create params_nbar (params_n a) in
let epp_matrix = matrix_create params_nbar params_nbar in
get_sp_ep_epp_matrices a seed_se sp_matrix ep_matrix epp_matrix;
crypto_kem_enc_ct0 a gen_a seed_a b mu sp_matrix ep_matrix epp_matrix ct;
clear_matrix3 a sp_matrix ep_matrix epp_matrix;
let h1 = ST.get () in
LSeq.eq_intro
(as_seq h1 ct)
(S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) (as_seq h0 seed_se));
pop_frame ()
#pop-options
inline_for_extraction noextract
val crypto_kem_enc_ss:
a:FP.frodo_alg
-> k:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> Stack unit
(requires fun h ->
live h k /\ live h ct /\ live h ss /\
disjoint ct ss /\ disjoint k ct /\ disjoint k ss)
(ensures fun h0 _ h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_enc_ss a (as_seq h0 k) (as_seq h0 ct))
let crypto_kem_enc_ss a k ct ss =
push_frame ();
let ss_init_len = crypto_ciphertextbytes a +! crypto_bytes a in
let shake_input_ss = create ss_init_len (u8 0) in
concat2 (crypto_ciphertextbytes a) ct (crypto_bytes a) k shake_input_ss;
frodo_shake a ss_init_len shake_input_ss (crypto_bytes a) ss;
clear_words_u8 shake_input_ss;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_seed_se_k:
a:FP.frodo_alg
-> mu:lbytes (bytes_mu a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h mu /\ live h pk /\ live h seed_se_k /\
disjoint seed_se_k mu /\ disjoint seed_se_k pk)
(ensures fun h0 _ h1 -> modifies (loc seed_se_k) h0 h1 /\
as_seq h1 seed_se_k == S.crypto_kem_enc_seed_se_k a (as_seq h0 mu) (as_seq h0 pk))
let crypto_kem_enc_seed_se_k a mu pk seed_se_k =
push_frame ();
let pkh_mu = create (bytes_pkhash a +! bytes_mu a) (u8 0) in
let h0 = ST.get () in
update_sub_f h0 pkh_mu 0ul (bytes_pkhash a)
(fun h -> FP.frodo_shake a (v (crypto_publickeybytes a)) (as_seq h0 pk) (v (bytes_pkhash a)))
(fun _ -> frodo_shake a (crypto_publickeybytes a) pk (bytes_pkhash a) (sub pkh_mu 0ul (bytes_pkhash a)));
let h1 = ST.get () in
update_sub pkh_mu (bytes_pkhash a) (bytes_mu a) mu;
let h2 = ST.get () in
LSeq.eq_intro
(LSeq.sub (as_seq h2 pkh_mu) 0 (v (bytes_pkhash a)))
(LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)));
LSeq.lemma_concat2
(v (bytes_pkhash a)) (LSeq.sub (as_seq h1 pkh_mu) 0 (v (bytes_pkhash a)))
(v (bytes_mu a)) (as_seq h0 mu) (as_seq h2 pkh_mu);
//concat2 (bytes_pkhash a) pkh (bytes_mu a) mu pkh_mu;
frodo_shake a (bytes_pkhash a +! bytes_mu a) pkh_mu (2ul *! crypto_bytes a) seed_se_k;
pop_frame ()
inline_for_extraction noextract
val crypto_kem_enc_ct_ss:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack unit
(requires fun h ->
live h seed_se_k /\ live h ct /\ live h ss /\ live h pk /\ live h mu /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint mu ss /\ disjoint mu ct /\ disjoint seed_se_k ct /\ disjoint seed_se_k ss)
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss) h0 h1 /\
(let seed_se = LSeq.sub (as_seq h0 seed_se_k) 0 (v (crypto_bytes a)) in
let k = LSeq.sub (as_seq h0 seed_se_k) (v (crypto_bytes a)) (v (crypto_bytes a)) in
as_seq h1 ct == S.crypto_kem_enc_ct a gen_a (as_seq h0 mu) (as_seq h0 pk) seed_se /\
as_seq h1 ss == S.crypto_kem_enc_ss a k (as_seq h1 ct)))
let crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk =
let seed_se = sub seed_se_k 0ul (crypto_bytes a) in
let k = sub seed_se_k (crypto_bytes a) (crypto_bytes a) in
crypto_kem_enc_ct a gen_a mu pk seed_se ct;
crypto_kem_enc_ss a k ct ss
inline_for_extraction noextract
val crypto_kem_enc0:
a:FP.frodo_alg
-> gen_a:FP.frodo_gen_a{is_supported gen_a}
-> mu:lbytes (bytes_mu a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> seed_se_k:lbytes (2ul *! crypto_bytes a)
-> Stack unit
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\ live h mu /\ live h seed_se_k /\
loc_pairwise_disjoint [loc mu; loc ct; loc ss; loc pk; loc seed_se_k])
(ensures fun h0 _ h1 -> modifies (loc ct |+| loc ss |+| loc seed_se_k) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc_ a gen_a (as_seq h0 mu) (as_seq h0 pk)) | {
"checked_file": "/",
"dependencies": [
"Spec.Matrix.fst.checked",
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.Encaps.fst.checked",
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Sample.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.Pack.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Impl.Frodo.Encode.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.Frodo.KEM.Encaps.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.Frodo.KEM.KeyGen",
"short_module": "KG"
},
{
"abbrev": true,
"full_module": "Spec.Matrix",
"short_module": "M"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM.Encaps",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "LB"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Sample",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Pack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.Encode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"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.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowStar.Buffer",
"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.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.Frodo.KEM",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a} ->
mu: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.bytes_mu a) ->
ct: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_ciphertextbytes a) ->
ss: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_bytes a) ->
pk: Hacl.Impl.Matrix.lbytes (Hacl.Impl.Frodo.Params.crypto_publickeybytes a) ->
seed_se_k: Hacl.Impl.Matrix.lbytes (2ul *! Hacl.Impl.Frodo.Params.crypto_bytes a)
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | []
| []
| [
"Spec.Frodo.Params.frodo_alg",
"Spec.Frodo.Params.frodo_gen_a",
"Prims.b2t",
"Hacl.Impl.Frodo.Params.is_supported",
"Hacl.Impl.Matrix.lbytes",
"Hacl.Impl.Frodo.Params.bytes_mu",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"FStar.UInt32.__uint_to_t",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_ct_ss",
"Prims.unit",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc_seed_se_k"
]
| []
| false | true | false | false | false | let crypto_kem_enc0 a gen_a mu ct ss pk seed_se_k =
| crypto_kem_enc_seed_se_k a mu pk seed_se_k;
crypto_kem_enc_ct_ss a gen_a seed_se_k mu ct ss pk | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.load_row | val load_row (#a: alg) (s: lseq (word_t a) 4) : row a | val load_row (#a: alg) (s: lseq (word_t a) 4) : row a | let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]] | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 38,
"end_line": 71,
"start_col": 0,
"start_line": 70
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | s: Lib.Sequence.lseq (Spec.Blake2.Definitions.word_t a) 4 -> Spec.Blake2.Definitions.row a | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Lib.Sequence.lseq",
"Spec.Blake2.Definitions.word_t",
"Lib.Sequence.createL",
"Prims.Cons",
"Lib.Sequence.op_String_Access",
"Prims.Nil",
"Spec.Blake2.Definitions.row"
]
| []
| false | false | false | false | false | let load_row (#a: alg) (s: lseq (word_t a) 4) : row a =
| createL [s.[ 0 ]; s.[ 1 ]; s.[ 2 ]; s.[ 3 ]] | false |
Vale.PPC64LE.Memory_Sems.fsti | Vale.PPC64LE.Memory_Sems.is_full_read | val is_full_read : h1: Vale.PPC64LE.Memory.vale_heap ->
h2: Vale.PPC64LE.Memory.vale_heap ->
b: Vale.PPC64LE.Memory.buffer t ->
i: Prims.int
-> Prims.logical | let is_full_read (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) (i:int) =
buffer_addr b h1 == buffer_addr b h2 /\
buffer_read b i h1 == buffer_read b i h2 /\
valid_buffer_read h1 b i | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory_Sems.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 26,
"end_line": 48,
"start_col": 0,
"start_line": 45
} | module Vale.PPC64LE.Memory_Sems
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Arch.MachineHeap_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.Lib.Seqs
module S = Vale.PPC64LE.Semantics_s
module Map16 = Vale.Lib.Map16
val same_domain (h:vale_heap) (m:S.machine_heap) : prop0
val lemma_same_domains (h:vale_heap) (m1:S.machine_heap) (m2:S.machine_heap) : Lemma
(requires same_domain h m1 /\ Set.equal (Map.domain m1) (Map.domain m2))
(ensures same_domain h m2)
val get_heap (h:vale_heap) : GTot (m:S.machine_heap{same_domain h m})
val upd_heap (h:vale_heap) (m:S.machine_heap{is_machine_heap_update (get_heap h) m}) : GTot vale_heap
//val lemma_upd_get_heap (h:vale_heap) : Lemma (upd_heap h (get_heap h) == h)
// [SMTPat (upd_heap h (get_heap h))]
val lemma_get_upd_heap (h:vale_heap) (m:S.machine_heap) : Lemma
(requires is_machine_heap_update (get_heap h) m)
(ensures get_heap (upd_heap h m) == m)
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
val lemma_heap_impl : squash (heap_impl == vale_full_heap)
val lemma_heap_get_heap (h:vale_full_heap) : Lemma
(heap_get (coerce h) == get_heap (get_vale_heap h))
[SMTPat (heap_get (coerce h))]
val lemma_heap_taint (h:vale_full_heap) : Lemma
(heap_taint (coerce h) == full_heap_taint h)
[SMTPat (heap_taint (coerce h))] | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Memory_Sems.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false |
h1: Vale.PPC64LE.Memory.vale_heap ->
h2: Vale.PPC64LE.Memory.vale_heap ->
b: Vale.PPC64LE.Memory.buffer t ->
i: Prims.int
-> Prims.logical | Prims.Tot | [
"total"
]
| []
| [
"Vale.Arch.HeapTypes_s.base_typ",
"Vale.PPC64LE.Memory.vale_heap",
"Vale.PPC64LE.Memory.buffer",
"Prims.int",
"Prims.l_and",
"Prims.eq2",
"Vale.PPC64LE.Memory.buffer_addr",
"Vale.PPC64LE.Memory.base_typ_as_vale_type",
"Vale.PPC64LE.Memory.buffer_read",
"Vale.PPC64LE.Memory.valid_buffer_read",
"Prims.logical"
]
| []
| false | false | false | false | true | let is_full_read (#t: base_typ) (h1 h2: vale_heap) (b: buffer t) (i: int) =
| buffer_addr b h1 == buffer_addr b h2 /\ buffer_read b i h1 == buffer_read b i h2 /\
valid_buffer_read h1 b i | false |
|
Vale.PPC64LE.Memory_Sems.fsti | Vale.PPC64LE.Memory_Sems.coerce | val coerce (#b #a: Type) (x: a{a == b}) : b | val coerce (#b #a: Type) (x: a{a == b}) : b | let coerce (#b #a:Type) (x:a{a == b}) : b = x | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory_Sems.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 33,
"start_col": 7,
"start_line": 33
} | module Vale.PPC64LE.Memory_Sems
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Arch.MachineHeap_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.Lib.Seqs
module S = Vale.PPC64LE.Semantics_s
module Map16 = Vale.Lib.Map16
val same_domain (h:vale_heap) (m:S.machine_heap) : prop0
val lemma_same_domains (h:vale_heap) (m1:S.machine_heap) (m2:S.machine_heap) : Lemma
(requires same_domain h m1 /\ Set.equal (Map.domain m1) (Map.domain m2))
(ensures same_domain h m2)
val get_heap (h:vale_heap) : GTot (m:S.machine_heap{same_domain h m})
val upd_heap (h:vale_heap) (m:S.machine_heap{is_machine_heap_update (get_heap h) m}) : GTot vale_heap
//val lemma_upd_get_heap (h:vale_heap) : Lemma (upd_heap h (get_heap h) == h)
// [SMTPat (upd_heap h (get_heap h))]
val lemma_get_upd_heap (h:vale_heap) (m:S.machine_heap) : Lemma
(requires is_machine_heap_update (get_heap h) m)
(ensures get_heap (upd_heap h m) == m) | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Memory_Sems.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | x: a{a == b} -> b | Prims.Tot | [
"total"
]
| []
| [
"Prims.eq2"
]
| []
| false | false | false | false | false | let coerce (#b #a: Type) (x: a{a == b}) : b =
| x | false |
Vale.PPC64LE.Memory_Sems.fsti | Vale.PPC64LE.Memory_Sems.is_full_update | val is_full_update : vfh: Vale.PPC64LE.Memory.vale_full_heap ->
h': Vale.PPC64LE.Memory.vale_heap ->
hid: Vale.PPC64LE.Memory.heaplet_id ->
mh': Vale.Arch.MachineHeap_s.machine_heap ->
mt': Vale.PPC64LE.Memory.memtaint
-> Prims.logical | let is_full_update (vfh:vale_full_heap) (h':vale_heap) (hid:heaplet_id) (mh':machine_heap) (mt':memtaint) =
is_machine_heap_update (heap_get (coerce vfh)) mh' /\ (
let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in
mem_inv vfh' /\
vfh'.vf_layout == vfh.vf_layout /\
vfh'.vf_heaplets == Map16.upd vfh.vf_heaplets hid h'
) | {
"file_name": "vale/code/arch/ppc64le/Vale.PPC64LE.Memory_Sems.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 56,
"start_col": 0,
"start_line": 50
} | module Vale.PPC64LE.Memory_Sems
open FStar.Mul
open Vale.Def.Prop_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.Arch.Heap
open Vale.Arch.MachineHeap_s
open Vale.PPC64LE.Machine_s
open Vale.PPC64LE.Memory
open Vale.Lib.Seqs
module S = Vale.PPC64LE.Semantics_s
module Map16 = Vale.Lib.Map16
val same_domain (h:vale_heap) (m:S.machine_heap) : prop0
val lemma_same_domains (h:vale_heap) (m1:S.machine_heap) (m2:S.machine_heap) : Lemma
(requires same_domain h m1 /\ Set.equal (Map.domain m1) (Map.domain m2))
(ensures same_domain h m2)
val get_heap (h:vale_heap) : GTot (m:S.machine_heap{same_domain h m})
val upd_heap (h:vale_heap) (m:S.machine_heap{is_machine_heap_update (get_heap h) m}) : GTot vale_heap
//val lemma_upd_get_heap (h:vale_heap) : Lemma (upd_heap h (get_heap h) == h)
// [SMTPat (upd_heap h (get_heap h))]
val lemma_get_upd_heap (h:vale_heap) (m:S.machine_heap) : Lemma
(requires is_machine_heap_update (get_heap h) m)
(ensures get_heap (upd_heap h m) == m)
unfold let coerce (#b #a:Type) (x:a{a == b}) : b = x
val lemma_heap_impl : squash (heap_impl == vale_full_heap)
val lemma_heap_get_heap (h:vale_full_heap) : Lemma
(heap_get (coerce h) == get_heap (get_vale_heap h))
[SMTPat (heap_get (coerce h))]
val lemma_heap_taint (h:vale_full_heap) : Lemma
(heap_taint (coerce h) == full_heap_taint h)
[SMTPat (heap_taint (coerce h))]
let is_full_read (#t:base_typ) (h1 h2:vale_heap) (b:buffer t) (i:int) =
buffer_addr b h1 == buffer_addr b h2 /\
buffer_read b i h1 == buffer_read b i h2 /\
valid_buffer_read h1 b i // needed to trigger "index = i" in valid_mem_operand64/valid_mem_operand128 | {
"checked_file": "/",
"dependencies": [
"Vale.PPC64LE.Semantics_s.fst.checked",
"Vale.PPC64LE.Memory.fsti.checked",
"Vale.PPC64LE.Machine_s.fst.checked",
"Vale.Lib.Seqs.fsti.checked",
"Vale.Lib.Map16.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.MachineHeap_s.fst.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.Arch.Heap.fsti.checked",
"prims.fst.checked",
"FStar.Set.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Map.fsti.checked"
],
"interface_file": false,
"source_file": "Vale.PPC64LE.Memory_Sems.fsti"
} | [
{
"abbrev": true,
"full_module": "Vale.Lib.Map16",
"short_module": "Map16"
},
{
"abbrev": true,
"full_module": "Vale.PPC64LE.Semantics_s",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Vale.Lib.Seqs",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.MachineHeap_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Heap",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.HeapImpl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Arch.Types",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.PPC64LE",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false |
vfh: Vale.PPC64LE.Memory.vale_full_heap ->
h': Vale.PPC64LE.Memory.vale_heap ->
hid: Vale.PPC64LE.Memory.heaplet_id ->
mh': Vale.Arch.MachineHeap_s.machine_heap ->
mt': Vale.PPC64LE.Memory.memtaint
-> Prims.logical | Prims.Tot | [
"total"
]
| []
| [
"Vale.PPC64LE.Memory.vale_full_heap",
"Vale.PPC64LE.Memory.vale_heap",
"Vale.PPC64LE.Memory.heaplet_id",
"Vale.Arch.MachineHeap_s.machine_heap",
"Vale.PPC64LE.Memory.memtaint",
"Prims.l_and",
"Vale.Arch.MachineHeap_s.is_machine_heap_update",
"Vale.Arch.Heap.heap_get",
"Vale.PPC64LE.Memory_Sems.coerce",
"Vale.Arch.Heap.heap_impl",
"Vale.PPC64LE.Memory.mem_inv",
"Prims.eq2",
"Vale.Arch.HeapImpl.vale_heap_layout",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_layout",
"Vale.Lib.Map16.map16",
"Vale.Arch.HeapImpl.vale_heap",
"Vale.Arch.HeapImpl.__proj__Mkvale_full_heap__item__vf_heaplets",
"Vale.Lib.Map16.upd",
"Vale.Arch.HeapImpl.vale_full_heap",
"Vale.Arch.Heap.heap_upd",
"Prims.logical"
]
| []
| false | false | false | true | true | let is_full_update
(vfh: vale_full_heap)
(h': vale_heap)
(hid: heaplet_id)
(mh': machine_heap)
(mt': memtaint)
=
| is_machine_heap_update (heap_get (coerce vfh)) mh' /\
(let vfh' = coerce (heap_upd (coerce vfh) mh' mt') in
mem_inv vfh' /\ vfh'.vf_layout == vfh.vf_layout /\
vfh'.vf_heaplets == Map16.upd vfh.vf_heaplets hid h') | false |
|
Rewrite.Monoid.fst | Rewrite.Monoid.is_reifiable | val is_reifiable (m_mult m_unit me: term) : Tac bool | val is_reifiable (m_mult m_unit me: term) : Tac bool | let is_reifiable (m_mult:term) (m_unit:term) (me:term) : Tac bool =
let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
// if unify (pack (Tv_FVar fv)) (quote (Monoid?.mult m)) then -- doesn't work
let t1 = norm_term [delta;zeta;iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ ->
term_eq (norm_term [delta;zeta;iota] me) m_unit | {
"file_name": "examples/tactics/Rewrite.Monoid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 52,
"end_line": 32,
"start_col": 0,
"start_line": 24
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Rewrite.Monoid
open FStar.Algebra.Monoid
open FStar.List
open FStar.Reflection.V2
open FStar.Tactics.V2
open FStar.Tactics.CanonMonoid | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonMonoid.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked",
"FStar.Algebra.Monoid.fst.checked"
],
"interface_file": false,
"source_file": "Rewrite.Monoid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.Monoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
m_mult: FStar.Tactics.NamedView.term ->
m_unit: FStar.Tactics.NamedView.term ->
me: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac Prims.bool | FStar.Tactics.Effect.Tac | []
| []
| [
"FStar.Tactics.NamedView.term",
"FStar.Stubs.Reflection.Types.term",
"Prims.l_or",
"Prims.eq2",
"Prims.precedes",
"Prims.list",
"FStar.Stubs.Reflection.V2.Data.argv",
"FStar.Pervasives.Native.fst",
"FStar.Stubs.Reflection.V2.Data.aqualv",
"FStar.Stubs.Reflection.Types.fv",
"FStar.Stubs.Reflection.V2.Builtins.term_eq",
"Prims.bool",
"FStar.Tactics.V2.Derived.norm_term",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"Prims.Nil",
"FStar.Tactics.NamedView.pack",
"FStar.Tactics.NamedView.Tv_FVar",
"FStar.Tactics.NamedView.named_term_view",
"FStar.Tactics.NamedView.inspect",
"FStar.Pervasives.Native.tuple2",
"FStar.Reflection.V2.Derived.Lemmas.collect_app_ref"
]
| []
| false | true | false | false | false | let is_reifiable (m_mult m_unit me: term) : Tac bool =
| let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
let t1 = norm_term [delta; zeta; iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ -> term_eq (norm_term [delta; zeta; iota] me) m_unit | false |
Rewrite.Monoid.fst | Rewrite.Monoid.replace_point | val replace_point : m: FStar.Algebra.Monoid.monoid a -> rhs: FStar.Tactics.CanonMonoid.exp a
-> FStar.Tactics.Effect.Tac Prims.unit | let replace_point (#a:Type) (m:monoid a) (rhs:exp a) =
focus (fun () ->
let t =
mk_app (`monoid_reflect_rhs)
[(quote a, Q_Explicit);
(quote m, Q_Explicit);
(quote rhs, Q_Explicit)] in
(* dump "before replace point"; *)
apply_lemma t;
(* dump "after replace point"; *)
norm [delta;primops;zeta;iota];
(* dump "after replace norm"; *)
trefl ()) | {
"file_name": "examples/tactics/Rewrite.Monoid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 53,
"start_col": 0,
"start_line": 41
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Rewrite.Monoid
open FStar.Algebra.Monoid
open FStar.List
open FStar.Reflection.V2
open FStar.Tactics.V2
open FStar.Tactics.CanonMonoid
let is_reifiable (m_mult:term) (m_unit:term) (me:term) : Tac bool =
let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
// if unify (pack (Tv_FVar fv)) (quote (Monoid?.mult m)) then -- doesn't work
let t1 = norm_term [delta;zeta;iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ ->
term_eq (norm_term [delta;zeta;iota] me) m_unit
let aux (#a:Type) (#rhs:a) (#lhs:a) (_:squash (lhs == rhs)) : Lemma (lhs == rhs) = ()
let monoid_reflect_rhs (a:Type) (m:monoid a) (rhs:exp a) (lhs:a)
(_ : squash (lhs == mdenote m rhs))
: Lemma (lhs == mldenote m (flatten rhs)) =
flatten_correct m rhs | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonMonoid.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked",
"FStar.Algebra.Monoid.fst.checked"
],
"interface_file": false,
"source_file": "Rewrite.Monoid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.Monoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | m: FStar.Algebra.Monoid.monoid a -> rhs: FStar.Tactics.CanonMonoid.exp a
-> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | []
| []
| [
"FStar.Algebra.Monoid.monoid",
"FStar.Tactics.CanonMonoid.exp",
"FStar.Tactics.V2.Derived.focus",
"Prims.unit",
"FStar.Tactics.V2.Derived.trefl",
"FStar.Stubs.Tactics.V2.Builtins.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta",
"FStar.Pervasives.primops",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"Prims.Nil",
"FStar.Tactics.V2.Derived.apply_lemma",
"FStar.Stubs.Reflection.Types.term",
"FStar.Reflection.V2.Derived.mk_app",
"Prims.list",
"FStar.Stubs.Reflection.V2.Data.argv",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.Reflection.V2.Data.aqualv",
"FStar.Stubs.Reflection.V2.Data.Q_Explicit"
]
| []
| false | true | false | false | false | let replace_point (#a: Type) (m: monoid a) (rhs: exp a) =
| focus (fun () ->
let t =
mk_app (`monoid_reflect_rhs)
[((quote a), Q_Explicit); ((quote m), Q_Explicit); ((quote rhs), Q_Explicit)]
in
apply_lemma t;
norm [delta; primops; zeta; iota];
trefl ()) | false |
|
Rewrite.Monoid.fst | Rewrite.Monoid.rewrite_int | val rewrite_int : everywhere: Prims.bool -> FStar.Tactics.Effect.Tac Prims.unit | let rewrite_int (everywhere:bool) =
topdown_rewrite
(should_rewrite int_plus_monoid everywhere)
(rewrite_monoid int_plus_monoid) | {
"file_name": "examples/tactics/Rewrite.Monoid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 42,
"end_line": 82,
"start_col": 0,
"start_line": 79
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Rewrite.Monoid
open FStar.Algebra.Monoid
open FStar.List
open FStar.Reflection.V2
open FStar.Tactics.V2
open FStar.Tactics.CanonMonoid
let is_reifiable (m_mult:term) (m_unit:term) (me:term) : Tac bool =
let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
// if unify (pack (Tv_FVar fv)) (quote (Monoid?.mult m)) then -- doesn't work
let t1 = norm_term [delta;zeta;iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ ->
term_eq (norm_term [delta;zeta;iota] me) m_unit
let aux (#a:Type) (#rhs:a) (#lhs:a) (_:squash (lhs == rhs)) : Lemma (lhs == rhs) = ()
let monoid_reflect_rhs (a:Type) (m:monoid a) (rhs:exp a) (lhs:a)
(_ : squash (lhs == mdenote m rhs))
: Lemma (lhs == mldenote m (flatten rhs)) =
flatten_correct m rhs
let replace_point (#a:Type) (m:monoid a) (rhs:exp a) =
focus (fun () ->
let t =
mk_app (`monoid_reflect_rhs)
[(quote a, Q_Explicit);
(quote m, Q_Explicit);
(quote rhs, Q_Explicit)] in
(* dump "before replace point"; *)
apply_lemma t;
(* dump "after replace point"; *)
norm [delta;primops;zeta;iota];
(* dump "after replace norm"; *)
trefl ())
let should_rewrite (#a:Type) (m:monoid a) (everywhere:bool) (t:term) : Tac (bool * int) =
let m_mult = norm_term [delta;zeta;iota] (quote (Monoid?.mult m)) in
let m_unit = norm_term [delta;zeta;iota] (quote (Monoid?.unit m)) in
// debug "should_rewrite: ";
// debug (term_to_string t);
if is_reifiable m_mult m_unit t
then true, (if everywhere then 1 else 2)
else false, 0
let rewrite_monoid (#a:Type) (m:monoid a) () : Tac unit =
norm [zeta;iota];
let g = cur_goal () in
match term_as_formula g with
| Comp (Eq (Some t)) lhs _ ->
debug (term_to_string g);
if term_eq t (quote a) then
// let _ = dump "Trying canon ... " in
let lhs_exp : exp a = reification m lhs in
replace_point m lhs_exp
// dump "change"
else trefl ()
| _ ->
fail "Unexpected goal to rewriter" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonMonoid.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked",
"FStar.Algebra.Monoid.fst.checked"
],
"interface_file": false,
"source_file": "Rewrite.Monoid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.Monoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | everywhere: Prims.bool -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | []
| []
| [
"Prims.bool",
"FStar.Tactics.V2.Derived.topdown_rewrite",
"Rewrite.Monoid.should_rewrite",
"Prims.int",
"FStar.Algebra.Monoid.int_plus_monoid",
"Rewrite.Monoid.rewrite_monoid",
"Prims.unit"
]
| []
| false | true | false | false | false | let rewrite_int (everywhere: bool) =
| topdown_rewrite (should_rewrite int_plus_monoid everywhere) (rewrite_monoid int_plus_monoid) | false |
|
Rewrite.Monoid.fst | Rewrite.Monoid.should_rewrite | val should_rewrite (#a: Type) (m: monoid a) (everywhere: bool) (t: term) : Tac (bool * int) | val should_rewrite (#a: Type) (m: monoid a) (everywhere: bool) (t: term) : Tac (bool * int) | let should_rewrite (#a:Type) (m:monoid a) (everywhere:bool) (t:term) : Tac (bool * int) =
let m_mult = norm_term [delta;zeta;iota] (quote (Monoid?.mult m)) in
let m_unit = norm_term [delta;zeta;iota] (quote (Monoid?.unit m)) in
// debug "should_rewrite: ";
// debug (term_to_string t);
if is_reifiable m_mult m_unit t
then true, (if everywhere then 1 else 2)
else false, 0 | {
"file_name": "examples/tactics/Rewrite.Monoid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 15,
"end_line": 62,
"start_col": 0,
"start_line": 55
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Rewrite.Monoid
open FStar.Algebra.Monoid
open FStar.List
open FStar.Reflection.V2
open FStar.Tactics.V2
open FStar.Tactics.CanonMonoid
let is_reifiable (m_mult:term) (m_unit:term) (me:term) : Tac bool =
let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
// if unify (pack (Tv_FVar fv)) (quote (Monoid?.mult m)) then -- doesn't work
let t1 = norm_term [delta;zeta;iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ ->
term_eq (norm_term [delta;zeta;iota] me) m_unit
let aux (#a:Type) (#rhs:a) (#lhs:a) (_:squash (lhs == rhs)) : Lemma (lhs == rhs) = ()
let monoid_reflect_rhs (a:Type) (m:monoid a) (rhs:exp a) (lhs:a)
(_ : squash (lhs == mdenote m rhs))
: Lemma (lhs == mldenote m (flatten rhs)) =
flatten_correct m rhs
let replace_point (#a:Type) (m:monoid a) (rhs:exp a) =
focus (fun () ->
let t =
mk_app (`monoid_reflect_rhs)
[(quote a, Q_Explicit);
(quote m, Q_Explicit);
(quote rhs, Q_Explicit)] in
(* dump "before replace point"; *)
apply_lemma t;
(* dump "after replace point"; *)
norm [delta;primops;zeta;iota];
(* dump "after replace norm"; *)
trefl ()) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonMonoid.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked",
"FStar.Algebra.Monoid.fst.checked"
],
"interface_file": false,
"source_file": "Rewrite.Monoid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.Monoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | m: FStar.Algebra.Monoid.monoid a -> everywhere: Prims.bool -> t: FStar.Tactics.NamedView.term
-> FStar.Tactics.Effect.Tac (Prims.bool * Prims.int) | FStar.Tactics.Effect.Tac | []
| []
| [
"FStar.Algebra.Monoid.monoid",
"Prims.bool",
"FStar.Tactics.NamedView.term",
"FStar.Pervasives.Native.Mktuple2",
"Prims.int",
"FStar.Pervasives.Native.tuple2",
"Rewrite.Monoid.is_reifiable",
"FStar.Tactics.V2.Derived.norm_term",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"Prims.Nil",
"FStar.Algebra.Monoid.__proj__Monoid__item__unit",
"FStar.Stubs.Reflection.Types.term",
"FStar.Algebra.Monoid.__proj__Monoid__item__mult"
]
| []
| false | true | false | false | false | let should_rewrite (#a: Type) (m: monoid a) (everywhere: bool) (t: term) : Tac (bool * int) =
| let m_mult = norm_term [delta; zeta; iota] (quote (Monoid?.mult m)) in
let m_unit = norm_term [delta; zeta; iota] (quote (Monoid?.unit m)) in
if is_reifiable m_mult m_unit t then true, (if everywhere then 1 else 2) else false, 0 | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divides_plus | val divides_plus (a b d:int) : Lemma
(requires d `divides` a /\ d `divides` b)
(ensures d `divides` (a + b)) | val divides_plus (a b d:int) : Lemma
(requires d `divides` a /\ d `divides` b)
(ensures d `divides` (a + b)) | let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2))) | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 69,
"end_line": 81,
"start_col": 0,
"start_line": 74
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> d: Prims.int
-> FStar.Pervasives.Lemma
(requires FStar.Math.Euclid.divides d a /\ FStar.Math.Euclid.divides d b)
(ensures FStar.Math.Euclid.divides d (a + b)) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Classical.exists_elim",
"FStar.Math.Euclid.divides",
"Prims.op_Addition",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Mul.op_Star",
"FStar.Squash.get_proof",
"Prims.l_Exists",
"FStar.Classical.exists_intro",
"Prims.unit",
"FStar.Math.Lemmas.distributivity_add_left",
"Prims._assert",
"Prims.squash"
]
| []
| false | false | true | false | false | let divides_plus a b d =
| Classical.exists_elim (d `divides` (a + b))
(Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b))
(Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2))) | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divides_0 | val divides_0 (a:int) : Lemma (a `divides` 0) | val divides_0 (a:int) : Lemma (a `divides` 0) | let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0 | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 47,
"end_line": 60,
"start_col": 0,
"start_line": 59
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> FStar.Pervasives.Lemma (ensures FStar.Math.Euclid.divides a 0) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Classical.exists_intro",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Mul.op_Star",
"Prims.unit"
]
| []
| false | false | true | false | false | let divides_0 a =
| Classical.exists_intro (fun q -> 0 = q * a) 0 | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.is_gcd_unique | val is_gcd_unique (a b c d:int) : Lemma
(requires is_gcd a b c /\ is_gcd a b d)
(ensures c = d \/ c = -d) | val is_gcd_unique (a b c d:int) : Lemma
(requires is_gcd a b c /\ is_gcd a b d)
(ensures c = d \/ c = -d) | let is_gcd_unique a b c d =
divide_antisym c d | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 20,
"end_line": 105,
"start_col": 0,
"start_line": 104
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
///
let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b)
let divides_mod a b =
Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a))
(fun q -> cancel_mul_div q b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> c: Prims.int -> d: Prims.int
-> FStar.Pervasives.Lemma
(requires FStar.Math.Euclid.is_gcd a b c /\ FStar.Math.Euclid.is_gcd a b d)
(ensures c = d \/ c = - d) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Math.Euclid.divide_antisym",
"Prims.unit"
]
| []
| true | false | true | false | false | let is_gcd_unique a b c d =
| divide_antisym c d | false |
Rewrite.Monoid.fst | Rewrite.Monoid.rewrite_monoid | val rewrite_monoid: #a: Type -> m: monoid a -> Prims.unit -> Tac unit | val rewrite_monoid: #a: Type -> m: monoid a -> Prims.unit -> Tac unit | let rewrite_monoid (#a:Type) (m:monoid a) () : Tac unit =
norm [zeta;iota];
let g = cur_goal () in
match term_as_formula g with
| Comp (Eq (Some t)) lhs _ ->
debug (term_to_string g);
if term_eq t (quote a) then
// let _ = dump "Trying canon ... " in
let lhs_exp : exp a = reification m lhs in
replace_point m lhs_exp
// dump "change"
else trefl ()
| _ ->
fail "Unexpected goal to rewriter" | {
"file_name": "examples/tactics/Rewrite.Monoid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 38,
"end_line": 77,
"start_col": 0,
"start_line": 64
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Rewrite.Monoid
open FStar.Algebra.Monoid
open FStar.List
open FStar.Reflection.V2
open FStar.Tactics.V2
open FStar.Tactics.CanonMonoid
let is_reifiable (m_mult:term) (m_unit:term) (me:term) : Tac bool =
let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
// if unify (pack (Tv_FVar fv)) (quote (Monoid?.mult m)) then -- doesn't work
let t1 = norm_term [delta;zeta;iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ ->
term_eq (norm_term [delta;zeta;iota] me) m_unit
let aux (#a:Type) (#rhs:a) (#lhs:a) (_:squash (lhs == rhs)) : Lemma (lhs == rhs) = ()
let monoid_reflect_rhs (a:Type) (m:monoid a) (rhs:exp a) (lhs:a)
(_ : squash (lhs == mdenote m rhs))
: Lemma (lhs == mldenote m (flatten rhs)) =
flatten_correct m rhs
let replace_point (#a:Type) (m:monoid a) (rhs:exp a) =
focus (fun () ->
let t =
mk_app (`monoid_reflect_rhs)
[(quote a, Q_Explicit);
(quote m, Q_Explicit);
(quote rhs, Q_Explicit)] in
(* dump "before replace point"; *)
apply_lemma t;
(* dump "after replace point"; *)
norm [delta;primops;zeta;iota];
(* dump "after replace norm"; *)
trefl ())
let should_rewrite (#a:Type) (m:monoid a) (everywhere:bool) (t:term) : Tac (bool * int) =
let m_mult = norm_term [delta;zeta;iota] (quote (Monoid?.mult m)) in
let m_unit = norm_term [delta;zeta;iota] (quote (Monoid?.unit m)) in
// debug "should_rewrite: ";
// debug (term_to_string t);
if is_reifiable m_mult m_unit t
then true, (if everywhere then 1 else 2)
else false, 0 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonMonoid.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked",
"FStar.Algebra.Monoid.fst.checked"
],
"interface_file": false,
"source_file": "Rewrite.Monoid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.Monoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | m: FStar.Algebra.Monoid.monoid a -> _: Prims.unit -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | []
| []
| [
"FStar.Algebra.Monoid.monoid",
"Prims.unit",
"FStar.Stubs.Reflection.Types.typ",
"FStar.Tactics.NamedView.term",
"Rewrite.Monoid.replace_point",
"FStar.Tactics.CanonMonoid.exp",
"FStar.Tactics.CanonMonoid.reification",
"Prims.bool",
"FStar.Tactics.V2.Derived.trefl",
"FStar.Stubs.Reflection.V2.Builtins.term_eq",
"FStar.Stubs.Reflection.Types.term",
"FStar.Tactics.V2.Derived.debug",
"Prims.string",
"FStar.Stubs.Tactics.V2.Builtins.term_to_string",
"FStar.Reflection.V2.Formula.formula",
"FStar.Tactics.V2.Derived.fail",
"FStar.Reflection.V2.Formula.term_as_formula",
"FStar.Tactics.V2.Derived.cur_goal",
"FStar.Stubs.Tactics.V2.Builtins.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"Prims.Nil"
]
| []
| false | true | false | false | false | let rewrite_monoid (#a: Type) (m: monoid a) () : Tac unit =
| norm [zeta; iota];
let g = cur_goal () in
match term_as_formula g with
| Comp (Eq (Some t)) lhs _ ->
debug (term_to_string g);
if term_eq t (quote a)
then
let lhs_exp:exp a = reification m lhs in
replace_point m lhs_exp
else trefl ()
| _ -> fail "Unexpected goal to rewriter" | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divides_reflexive | val divides_reflexive (a:int) : Lemma (a `divides` a) [SMTPat (a `divides` a)] | val divides_reflexive (a:int) : Lemma (a `divides` a) [SMTPat (a `divides` a)] | let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1 | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 47,
"end_line": 32,
"start_col": 0,
"start_line": 31
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
/// | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int
-> FStar.Pervasives.Lemma (ensures FStar.Math.Euclid.divides a a)
[SMTPat (FStar.Math.Euclid.divides a a)] | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Classical.exists_intro",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Mul.op_Star",
"Prims.unit"
]
| []
| false | false | true | false | false | let divides_reflexive a =
| Classical.exists_intro (fun q -> a = q * a) 1 | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divides_mod | val divides_mod (a:int) (b:nonzero) : Lemma (requires b `divides` a) (ensures a % b = 0) | val divides_mod (a:int) (b:nonzero) : Lemma (requires b `divides` a) (ensures a % b = 0) | let divides_mod a b =
Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a))
(fun q -> cancel_mul_div q b) | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 33,
"end_line": 102,
"start_col": 0,
"start_line": 100
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
///
let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.nonzero
-> FStar.Pervasives.Lemma (requires FStar.Math.Euclid.divides b a) (ensures a % b = 0) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"Prims.nonzero",
"FStar.Classical.exists_elim",
"Prims.b2t",
"Prims.op_Equality",
"Prims.op_Modulus",
"FStar.Mul.op_Star",
"FStar.Squash.get_proof",
"FStar.Math.Euclid.divides",
"FStar.Math.Lemmas.cancel_mul_div",
"Prims.squash",
"Prims.unit"
]
| []
| false | false | true | false | false | let divides_mod a b =
| Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a)) (fun q -> cancel_mul_div q b) | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.is_gcd_opp | val is_gcd_opp (a b d:int) : Lemma
(requires is_gcd a b d)
(ensures is_gcd b a (-d)) | val is_gcd_opp (a b d:int) : Lemma
(requires is_gcd a b d)
(ensures is_gcd b a (-d)) | let is_gcd_opp a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_opp d a;
divides_opp d b | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 17,
"end_line": 122,
"start_col": 0,
"start_line": 119
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
///
let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b)
let divides_mod a b =
Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a))
(fun q -> cancel_mul_div q b)
let is_gcd_unique a b c d =
divide_antisym c d
let is_gcd_reflexive a = ()
let is_gcd_symmetric a b d = ()
let is_gcd_0 a = ()
let is_gcd_1 a = ()
let is_gcd_minus a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
opp_idempotent b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> d: Prims.int
-> FStar.Pervasives.Lemma (requires FStar.Math.Euclid.is_gcd a b d)
(ensures FStar.Math.Euclid.is_gcd b a (- d)) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Math.Euclid.divides_opp",
"Prims.unit",
"FStar.Classical.forall_intro_2",
"Prims.l_imp",
"FStar.Math.Euclid.divides",
"Prims.op_Minus",
"FStar.Classical.move_requires_2",
"FStar.Math.Euclid.divides_minus"
]
| []
| false | false | true | false | false | let is_gcd_opp a b d =
| Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_opp d a;
divides_opp d b | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.is_gcd_minus | val is_gcd_minus (a b d:int) : Lemma
(requires is_gcd a (-b) d)
(ensures is_gcd b a d) | val is_gcd_minus (a b d:int) : Lemma
(requires is_gcd a (-b) d)
(ensures is_gcd b a d) | let is_gcd_minus a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
opp_idempotent b | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 18,
"end_line": 117,
"start_col": 0,
"start_line": 115
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
///
let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b)
let divides_mod a b =
Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a))
(fun q -> cancel_mul_div q b)
let is_gcd_unique a b c d =
divide_antisym c d
let is_gcd_reflexive a = ()
let is_gcd_symmetric a b d = ()
let is_gcd_0 a = ()
let is_gcd_1 a = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> d: Prims.int
-> FStar.Pervasives.Lemma (requires FStar.Math.Euclid.is_gcd a (- b) d)
(ensures FStar.Math.Euclid.is_gcd b a d) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Math.Euclid.opp_idempotent",
"Prims.unit",
"FStar.Classical.forall_intro_2",
"Prims.l_imp",
"FStar.Math.Euclid.divides",
"Prims.op_Minus",
"FStar.Classical.move_requires_2",
"FStar.Math.Euclid.divides_minus"
]
| []
| false | false | true | false | false | let is_gcd_minus a b d =
| Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
opp_idempotent b | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.is_gcd_for_euclid | val is_gcd_for_euclid (a b q d:int) : Lemma
(requires is_gcd b (a - q * b) d)
(ensures is_gcd a b d) | val is_gcd_for_euclid (a b q d:int) : Lemma
(requires is_gcd b (a - q * b) d)
(ensures is_gcd a b d) | let is_gcd_for_euclid a b q d =
add_sub_l a (q * b);
is_gcd_plus b (a - q * b) q d | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 31,
"end_line": 139,
"start_col": 0,
"start_line": 137
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
///
let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b)
let divides_mod a b =
Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a))
(fun q -> cancel_mul_div q b)
let is_gcd_unique a b c d =
divide_antisym c d
let is_gcd_reflexive a = ()
let is_gcd_symmetric a b d = ()
let is_gcd_0 a = ()
let is_gcd_1 a = ()
let is_gcd_minus a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
opp_idempotent b
let is_gcd_opp a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_opp d a;
divides_opp d b
let is_gcd_plus a b q d =
add_sub_r b (q * a);
Classical.forall_intro_3 (Classical.move_requires_3 divides_plus);
Classical.forall_intro_3 (Classical.move_requires_3 divides_mult_right);
Classical.forall_intro_3 (Classical.move_requires_3 divides_sub)
///
/// Extended Euclidean algorithm
///
val is_gcd_for_euclid (a b q d:int) : Lemma
(requires is_gcd b (a - q * b) d) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> q: Prims.int -> d: Prims.int
-> FStar.Pervasives.Lemma (requires FStar.Math.Euclid.is_gcd b (a - q * b) d)
(ensures FStar.Math.Euclid.is_gcd a b d) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Math.Euclid.is_gcd_plus",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"Prims.unit",
"FStar.Math.Euclid.add_sub_l"
]
| []
| true | false | true | false | false | let is_gcd_for_euclid a b q d =
| add_sub_l a (q * b);
is_gcd_plus b (a - q * b) q d | false |
Spec.Blake2.Definitions.fst | Spec.Blake2.Definitions.nat_to_limb | val nat_to_limb (a: alg) (x: nat{x <= max_limb a}) : xl: limb_t a {uint_v xl == x} | val nat_to_limb (a: alg) (x: nat{x <= max_limb a}) : xl: limb_t a {uint_v xl == x} | let nat_to_limb (a:alg) (x:nat{x <= max_limb a}) : xl:limb_t a{uint_v xl == x} =
match (wt a) with
| U32 -> u64 x
| U64 -> let h = u64 (x / pow2 64) in
let l = u64 (x % pow2 64) in
(to_u128 h <<. 64ul) +! to_u128 l | {
"file_name": "specs/Spec.Blake2.Definitions.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 237,
"start_col": 0,
"start_line": 232
} | module Spec.Blake2.Definitions
open FStar.Mul
open Lib.IntTypes
open Lib.RawIntTypes
open Lib.Sequence
open Lib.ByteSequence
#set-options "--z3rlimit 50"
type alg =
| Blake2S
| Blake2B
let alg_inversion_lemma (a:alg) : Lemma (a == Blake2S \/ a == Blake2B) = ()
inline_for_extraction
let wt (a:alg) : t:inttype{unsigned t} =
match a with
| Blake2S -> U32
| Blake2B -> U64
inline_for_extraction
let rounds (a:alg) =
match a with
| Blake2S -> 10
| Blake2B -> 12
(* Algorithm parameters *)
inline_for_extraction let size_hash_w : size_nat = 8
inline_for_extraction let size_block_w : size_nat = 16
inline_for_extraction let size_word (a:alg) : size_nat = numbytes (wt a)
inline_for_extraction let size_block (a:alg) : size_nat = size_block_w * (size_word a)
inline_for_extraction let size_ivTable : size_nat = 8
inline_for_extraction let size_sigmaTable : size_nat = 160
inline_for_extraction let max_key (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
inline_for_extraction let max_output (a:alg) =
match a with
| Blake2S -> 32
| Blake2B -> 64
(* Definition of base types *)
inline_for_extraction
unfold let limb_inttype (a:alg) =
match (wt a) with
| U32 -> U64
| U64 -> U128
inline_for_extraction
unfold type word_t (a:alg) = uint_t (wt a) SEC
inline_for_extraction
let zero (a:alg) : word_t a=
match a with
| Blake2S -> u32 0
| Blake2B -> u64 0
inline_for_extraction
unfold let row (a:alg) = lseq (word_t a) 4
inline_for_extraction
let zero_row (a:alg) : row a = create 4 (zero a)
inline_for_extraction
let load_row (#a:alg) (s:lseq (word_t a) 4) : row a =
createL [s.[0]; s.[1]; s.[2]; s.[3]]
inline_for_extraction
let create_row (#a:alg) x0 x1 x2 x3 : row a =
createL [x0;x1;x2;x3]
inline_for_extraction
unfold let state (a:alg) = lseq (row a) 4
inline_for_extraction
let salt_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
inline_for_extraction
let personal_length (a:alg) : size_nat =
match a with
| Blake2S -> 8
| Blake2B -> 16
noeq
type blake2s_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint16;
node_depth: uint8;
inner_length: uint8;
salt: lseq uint8 (salt_length Blake2S);
personal: lseq uint8 (personal_length Blake2S);
}
(* Need these helpers to cleanly work around field shadowing *)
inline_for_extraction
let set_blake2s_digest_length
(p: blake2s_params)
(nn: size_nat{1 <= nn /\ nn <= max_output Blake2S})
: blake2s_params =
{p with digest_length = u8 nn}
inline_for_extraction
let set_blake2s_key_length
(p: blake2s_params)
(kk: size_nat{kk <= max_key Blake2S})
: blake2s_params =
{p with key_length = u8 kk}
inline_for_extraction
let get_blake2s_salt (p:blake2s_params) = p.salt
inline_for_extraction
let get_blake2s_personal (p:blake2s_params) = p.personal
noeq
type blake2b_params = {
digest_length: uint8;
key_length: uint8;
fanout: uint8;
depth: uint8;
leaf_length: uint32;
node_offset: uint32;
xof_length: uint32;
node_depth: uint8;
inner_length: uint8;
// Blake2b also contains 14 reserved bytes here, but they seem
// unused and to only contain zeros, hence we do not expose them
salt: lseq uint8 (salt_length Blake2B);
personal: lseq uint8 (personal_length Blake2B);
}
inline_for_extraction
let blake2_params (a: alg) =
match a with
| Blake2S -> blake2s_params
| Blake2B -> blake2b_params
inline_for_extraction
let set_digest_length (#a: alg)
(p: blake2_params a)
(nn: size_nat{1 <= nn /\ nn <= max_output a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_digest_length p nn
| Blake2B -> {p with digest_length = u8 nn}
inline_for_extraction
let set_key_length (#a: alg)
(p: blake2_params a)
(kk: size_nat{kk <= max_key a})
: blake2_params a =
match a with
| Blake2S -> set_blake2s_key_length p kk
| Blake2B -> {p with key_length = u8 kk}
inline_for_extraction
let get_salt (#a: alg) (p: blake2_params a) : lseq uint8 (salt_length a) =
match a with
| Blake2S -> get_blake2s_salt p
| Blake2B -> p.salt
inline_for_extraction
let get_personal (#a: alg) (p: blake2_params a) : lseq uint8 (personal_length a) =
match a with
| Blake2S -> get_blake2s_personal p
| Blake2B -> p.personal
let blake2s_default_params: blake2s_params =
{ digest_length = u8 32;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u16 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 8 (u8 0);
personal = create 8 (u8 0);
}
let blake2b_default_params: blake2b_params =
{ digest_length = u8 64;
key_length = u8 0;
fanout = u8 1;
depth = u8 1;
leaf_length = u32 0;
node_offset = u32 0;
xof_length = u32 0;
node_depth = u8 0;
inner_length = u8 0;
salt = create 16 (u8 0);
personal = create 16 (u8 0);
}
inline_for_extraction
let blake2_default_params (a: alg) : blake2_params a =
match a with
| Blake2S -> blake2s_default_params
| Blake2B -> blake2b_default_params
inline_for_extraction
type pub_word_t (a:alg) = uint_t (wt a) PUB
inline_for_extraction
type limb_t (a:alg) : Type0 = uint_t (limb_inttype a) SEC
inline_for_extraction
let max_limb (a:alg) = maxint (limb_inttype a)
inline_for_extraction
let nat_to_word (a:alg) (x:size_nat) : word_t a =
match (wt a) with
| U32 -> u32 x
| U64 -> u64 x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteSequence.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": false,
"source_file": "Spec.Blake2.Definitions.fst"
} | [
{
"abbrev": false,
"full_module": "Lib.ByteSequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.RawIntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Spec.Blake2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Spec.Blake2.Definitions.alg -> x: Prims.nat{x <= Spec.Blake2.Definitions.max_limb a}
-> xl: Spec.Blake2.Definitions.limb_t a {Lib.IntTypes.uint_v xl == x} | Prims.Tot | [
"total"
]
| []
| [
"Spec.Blake2.Definitions.alg",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Spec.Blake2.Definitions.max_limb",
"Spec.Blake2.Definitions.wt",
"Lib.IntTypes.u64",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.U128",
"Lib.IntTypes.SEC",
"Lib.IntTypes.op_Less_Less_Dot",
"Lib.IntTypes.to_u128",
"Lib.IntTypes.U64",
"FStar.UInt32.__uint_to_t",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Prims.int",
"Lib.IntTypes.range",
"Lib.IntTypes.v",
"Prims.op_Modulus",
"Prims.pow2",
"Prims.op_Division",
"Spec.Blake2.Definitions.limb_t",
"Prims.l_or",
"Spec.Blake2.Definitions.limb_inttype",
"Prims.l_and",
"Prims.op_GreaterThanOrEqual",
"Lib.IntTypes.uint_v"
]
| []
| false | false | false | false | false | let nat_to_limb (a: alg) (x: nat{x <= max_limb a}) : xl: limb_t a {uint_v xl == x} =
| match (wt a) with
| U32 -> u64 x
| U64 ->
let h = u64 (x / pow2 64) in
let l = u64 (x % pow2 64) in
(to_u128 h <<. 64ul) +! to_u128 l | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divides_mult_right | val divides_mult_right (a b d:int) : Lemma
(requires d `divides` b)
(ensures d `divides` (a * b)) | val divides_mult_right (a b d:int) : Lemma
(requires d `divides` b)
(ensures d `divides` (a * b)) | let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q)) | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 62,
"end_line": 91,
"start_col": 0,
"start_line": 87
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> d: Prims.int
-> FStar.Pervasives.Lemma (requires FStar.Math.Euclid.divides d b)
(ensures FStar.Math.Euclid.divides d (a * b)) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Classical.exists_elim",
"FStar.Math.Euclid.divides",
"FStar.Mul.op_Star",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Squash.get_proof",
"FStar.Classical.exists_intro",
"Prims.unit",
"FStar.Math.Lemmas.paren_mul_right",
"Prims.squash"
]
| []
| false | false | true | false | false | let divides_mult_right a b d =
| Classical.exists_elim (d `divides` (a * b))
(Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q)) | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divide_antisym | val divide_antisym (a b:int) : Lemma
(requires a `divides` b /\ b `divides` a)
(ensures a = b \/ a = -b) | val divide_antisym (a b:int) : Lemma
(requires a `divides` b /\ b `divides` a)
(ensures a = b \/ a = -b) | let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2)) | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 31,
"end_line": 57,
"start_col": 0,
"start_line": 46
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int
-> FStar.Pervasives.Lemma
(requires FStar.Math.Euclid.divides a b /\ FStar.Math.Euclid.divides b a)
(ensures a = b \/ a = - b) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"Prims.op_disEquality",
"FStar.Classical.exists_elim",
"Prims.l_or",
"Prims.b2t",
"Prims.op_Equality",
"Prims.op_Minus",
"FStar.Mul.op_Star",
"FStar.Squash.get_proof",
"Prims.l_Exists",
"FStar.Math.Euclid.eq_mult_one",
"Prims.unit",
"FStar.Math.Euclid.eq_mult_left",
"FStar.Math.Lemmas.paren_mul_right",
"Prims._assert",
"Prims.squash",
"Prims.bool"
]
| []
| false | false | true | false | false | let divide_antisym a b =
| if a <> 0
then
Classical.exists_elim (a = b \/ a = - b)
(Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = - b)
(Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2)) | false |
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.four_map | val four_map (#a #b: Type) (f: (a -> b)) (x: four a) : four b | val four_map (#a #b: Type) (f: (a -> b)) (x: four a) : four b | let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3) | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 36,
"end_line": 7,
"start_col": 7,
"start_line": 5
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | f: (_: a -> b) -> x: Vale.Def.Words_s.four a -> Vale.Def.Words_s.four b | Prims.Tot | [
"total"
]
| []
| [
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.Mkfour"
]
| []
| false | false | false | true | false | let four_map (#a #b: Type) (f: (a -> b)) (x: four a) : four b =
| let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3) | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divides_transitive | val divides_transitive (a b c:int) : Lemma
(requires a `divides` b /\ b `divides` c)
(ensures a `divides` c) | val divides_transitive (a b c:int) : Lemma
(requires a `divides` b /\ b `divides` c)
(ensures a `divides` c) | let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and () | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 8,
"end_line": 43,
"start_col": 0,
"start_line": 34
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> c: Prims.int
-> FStar.Pervasives.Lemma
(requires FStar.Math.Euclid.divides a b /\ FStar.Math.Euclid.divides b c)
(ensures FStar.Math.Euclid.divides a c) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Classical.Sugar.exists_elim",
"Prims.eq2",
"FStar.Mul.op_Star",
"FStar.Math.Euclid.divides",
"Prims.squash",
"Prims.l_Exists",
"FStar.Classical.Sugar.exists_intro",
"Prims.unit"
]
| []
| false | false | true | false | false | let divides_transitive a b c =
| eliminate exists q1.
b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2.
c == q2 * b
returns _
with _pf2.
introduce exists q.c == q * a
with (q1 * q2)
and () | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.is_gcd_plus | val is_gcd_plus (a b q d:int) : Lemma
(requires is_gcd a b d)
(ensures is_gcd a (b + q * a) d) | val is_gcd_plus (a b q d:int) : Lemma
(requires is_gcd a b d)
(ensures is_gcd a (b + q * a) d) | let is_gcd_plus a b q d =
add_sub_r b (q * a);
Classical.forall_intro_3 (Classical.move_requires_3 divides_plus);
Classical.forall_intro_3 (Classical.move_requires_3 divides_mult_right);
Classical.forall_intro_3 (Classical.move_requires_3 divides_sub) | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 66,
"end_line": 128,
"start_col": 0,
"start_line": 124
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
///
let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b)
let divides_mod a b =
Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a))
(fun q -> cancel_mul_div q b)
let is_gcd_unique a b c d =
divide_antisym c d
let is_gcd_reflexive a = ()
let is_gcd_symmetric a b d = ()
let is_gcd_0 a = ()
let is_gcd_1 a = ()
let is_gcd_minus a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
opp_idempotent b
let is_gcd_opp a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_opp d a;
divides_opp d b | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> q: Prims.int -> d: Prims.int
-> FStar.Pervasives.Lemma (requires FStar.Math.Euclid.is_gcd a b d)
(ensures FStar.Math.Euclid.is_gcd a (b + q * a) d) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Classical.forall_intro_3",
"Prims.l_imp",
"Prims.l_and",
"FStar.Math.Euclid.divides",
"Prims.op_Subtraction",
"FStar.Classical.move_requires_3",
"FStar.Math.Euclid.divides_sub",
"Prims.unit",
"FStar.Mul.op_Star",
"FStar.Math.Euclid.divides_mult_right",
"Prims.op_Addition",
"FStar.Math.Euclid.divides_plus",
"FStar.Math.Euclid.add_sub_r"
]
| []
| false | false | true | false | false | let is_gcd_plus a b q d =
| add_sub_r b (q * a);
Classical.forall_intro_3 (Classical.move_requires_3 divides_plus);
Classical.forall_intro_3 (Classical.move_requires_3 divides_mult_right);
Classical.forall_intro_3 (Classical.move_requires_3 divides_sub) | false |
Rewrite.Monoid.fst | Rewrite.Monoid.apply_imp | val apply_imp : h: FStar.Tactics.NamedView.binding -> FStar.Tactics.Effect.Tac Prims.unit | let apply_imp (h:binding) =
mapply (mk_app (`elim_implies) [(pack (Tv_Var (binding_to_namedv h)), Q_Explicit)]) | {
"file_name": "examples/tactics/Rewrite.Monoid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 87,
"end_line": 86,
"start_col": 0,
"start_line": 85
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Rewrite.Monoid
open FStar.Algebra.Monoid
open FStar.List
open FStar.Reflection.V2
open FStar.Tactics.V2
open FStar.Tactics.CanonMonoid
let is_reifiable (m_mult:term) (m_unit:term) (me:term) : Tac bool =
let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
// if unify (pack (Tv_FVar fv)) (quote (Monoid?.mult m)) then -- doesn't work
let t1 = norm_term [delta;zeta;iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ ->
term_eq (norm_term [delta;zeta;iota] me) m_unit
let aux (#a:Type) (#rhs:a) (#lhs:a) (_:squash (lhs == rhs)) : Lemma (lhs == rhs) = ()
let monoid_reflect_rhs (a:Type) (m:monoid a) (rhs:exp a) (lhs:a)
(_ : squash (lhs == mdenote m rhs))
: Lemma (lhs == mldenote m (flatten rhs)) =
flatten_correct m rhs
let replace_point (#a:Type) (m:monoid a) (rhs:exp a) =
focus (fun () ->
let t =
mk_app (`monoid_reflect_rhs)
[(quote a, Q_Explicit);
(quote m, Q_Explicit);
(quote rhs, Q_Explicit)] in
(* dump "before replace point"; *)
apply_lemma t;
(* dump "after replace point"; *)
norm [delta;primops;zeta;iota];
(* dump "after replace norm"; *)
trefl ())
let should_rewrite (#a:Type) (m:monoid a) (everywhere:bool) (t:term) : Tac (bool * int) =
let m_mult = norm_term [delta;zeta;iota] (quote (Monoid?.mult m)) in
let m_unit = norm_term [delta;zeta;iota] (quote (Monoid?.unit m)) in
// debug "should_rewrite: ";
// debug (term_to_string t);
if is_reifiable m_mult m_unit t
then true, (if everywhere then 1 else 2)
else false, 0
let rewrite_monoid (#a:Type) (m:monoid a) () : Tac unit =
norm [zeta;iota];
let g = cur_goal () in
match term_as_formula g with
| Comp (Eq (Some t)) lhs _ ->
debug (term_to_string g);
if term_eq t (quote a) then
// let _ = dump "Trying canon ... " in
let lhs_exp : exp a = reification m lhs in
replace_point m lhs_exp
// dump "change"
else trefl ()
| _ ->
fail "Unexpected goal to rewriter"
let rewrite_int (everywhere:bool) =
topdown_rewrite
(should_rewrite int_plus_monoid everywhere)
(rewrite_monoid int_plus_monoid) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonMonoid.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked",
"FStar.Algebra.Monoid.fst.checked"
],
"interface_file": false,
"source_file": "Rewrite.Monoid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.Monoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | h: FStar.Tactics.NamedView.binding -> FStar.Tactics.Effect.Tac Prims.unit | FStar.Tactics.Effect.Tac | []
| []
| [
"FStar.Tactics.NamedView.binding",
"FStar.Tactics.MApply.mapply",
"FStar.Stubs.Reflection.Types.term",
"FStar.Tactics.MApply.termable_term",
"FStar.Reflection.V2.Derived.mk_app",
"Prims.Cons",
"FStar.Stubs.Reflection.V2.Data.argv",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Stubs.Reflection.V2.Data.aqualv",
"FStar.Tactics.NamedView.pack",
"FStar.Tactics.NamedView.Tv_Var",
"FStar.Tactics.V2.SyntaxCoercions.binding_to_namedv",
"FStar.Stubs.Reflection.V2.Data.Q_Explicit",
"Prims.Nil",
"Prims.unit"
]
| []
| false | true | false | false | false | let apply_imp (h: binding) =
| mapply (mk_app (`elim_implies) [(pack (Tv_Var (binding_to_namedv h)), Q_Explicit)]) | false |
|
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.two_two_to_four | val two_two_to_four (#a: Type) (x: two (two a)) : four a | val two_two_to_four (#a: Type) (x: two (two a)) : four a | let two_two_to_four (#a:Type) (x:two (two a)) : four a =
let (Mktwo (Mktwo x0 x1) (Mktwo x2 x3)) = x in
Mkfour x0 x1 x2 x3 | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 16,
"start_col": 0,
"start_line": 14
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul
unfold let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3)
unfold let four_map2 (#a #b:Type) (f:a -> a -> b) (x y:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | x: Vale.Def.Words_s.two (Vale.Def.Words_s.two a) -> Vale.Def.Words_s.four a | Prims.Tot | [
"total"
]
| []
| [
"Vale.Def.Words_s.two",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words_s.four"
]
| []
| false | false | false | true | false | let two_two_to_four (#a: Type) (x: two (two a)) : four a =
| let Mktwo (Mktwo x0 x1) (Mktwo x2 x3) = x in
Mkfour x0 x1 x2 x3 | false |
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.four_map2 | val four_map2 (#a #b: Type) (f: (a -> a -> b)) (x y: four a) : four b | val four_map2 (#a #b: Type) (f: (a -> a -> b)) (x y: four a) : four b | let four_map2 (#a #b:Type) (f:a -> a -> b) (x y:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3) | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 48,
"end_line": 12,
"start_col": 7,
"start_line": 9
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul
unfold let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | f: (_: a -> _: a -> b) -> x: Vale.Def.Words_s.four a -> y: Vale.Def.Words_s.four a
-> Vale.Def.Words_s.four b | Prims.Tot | [
"total"
]
| []
| [
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.Mkfour"
]
| []
| false | false | false | true | false | let four_map2 (#a #b: Type) (f: (a -> a -> b)) (x y: four a) : four b =
| let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3) | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.mod_divides | val mod_divides (a:int) (b:nonzero) : Lemma (requires a % b = 0) (ensures b `divides` a) | val mod_divides (a:int) (b:nonzero) : Lemma (requires a % b = 0) (ensures b `divides` a) | let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b) | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 53,
"end_line": 98,
"start_col": 0,
"start_line": 97
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
/// | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.nonzero
-> FStar.Pervasives.Lemma (requires a % b = 0) (ensures FStar.Math.Euclid.divides b a) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"Prims.nonzero",
"FStar.Classical.exists_intro",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Mul.op_Star",
"Prims.op_Division",
"Prims.unit"
]
| []
| false | false | true | false | false | let mod_divides a b =
| Classical.exists_intro (fun q -> a = q * b) (a / b) | false |
Rewrite.Monoid.fst | Rewrite.Monoid.refl | val refl (#a: Type) (x: a) : (x == x) | val refl (#a: Type) (x: a) : (x == x) | let refl (#a:Type) (x:a) : (x==x) = FStar.Squash.return_squash Refl | {
"file_name": "examples/tactics/Rewrite.Monoid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 67,
"end_line": 87,
"start_col": 0,
"start_line": 87
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Rewrite.Monoid
open FStar.Algebra.Monoid
open FStar.List
open FStar.Reflection.V2
open FStar.Tactics.V2
open FStar.Tactics.CanonMonoid
let is_reifiable (m_mult:term) (m_unit:term) (me:term) : Tac bool =
let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
// if unify (pack (Tv_FVar fv)) (quote (Monoid?.mult m)) then -- doesn't work
let t1 = norm_term [delta;zeta;iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ ->
term_eq (norm_term [delta;zeta;iota] me) m_unit
let aux (#a:Type) (#rhs:a) (#lhs:a) (_:squash (lhs == rhs)) : Lemma (lhs == rhs) = ()
let monoid_reflect_rhs (a:Type) (m:monoid a) (rhs:exp a) (lhs:a)
(_ : squash (lhs == mdenote m rhs))
: Lemma (lhs == mldenote m (flatten rhs)) =
flatten_correct m rhs
let replace_point (#a:Type) (m:monoid a) (rhs:exp a) =
focus (fun () ->
let t =
mk_app (`monoid_reflect_rhs)
[(quote a, Q_Explicit);
(quote m, Q_Explicit);
(quote rhs, Q_Explicit)] in
(* dump "before replace point"; *)
apply_lemma t;
(* dump "after replace point"; *)
norm [delta;primops;zeta;iota];
(* dump "after replace norm"; *)
trefl ())
let should_rewrite (#a:Type) (m:monoid a) (everywhere:bool) (t:term) : Tac (bool * int) =
let m_mult = norm_term [delta;zeta;iota] (quote (Monoid?.mult m)) in
let m_unit = norm_term [delta;zeta;iota] (quote (Monoid?.unit m)) in
// debug "should_rewrite: ";
// debug (term_to_string t);
if is_reifiable m_mult m_unit t
then true, (if everywhere then 1 else 2)
else false, 0
let rewrite_monoid (#a:Type) (m:monoid a) () : Tac unit =
norm [zeta;iota];
let g = cur_goal () in
match term_as_formula g with
| Comp (Eq (Some t)) lhs _ ->
debug (term_to_string g);
if term_eq t (quote a) then
// let _ = dump "Trying canon ... " in
let lhs_exp : exp a = reification m lhs in
replace_point m lhs_exp
// dump "change"
else trefl ()
| _ ->
fail "Unexpected goal to rewriter"
let rewrite_int (everywhere:bool) =
topdown_rewrite
(should_rewrite int_plus_monoid everywhere)
(rewrite_monoid int_plus_monoid)
let elim_implies #p #q (_:(p ==> q)) (_:p) : squash q = ()
let apply_imp (h:binding) = | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonMonoid.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked",
"FStar.Algebra.Monoid.fst.checked"
],
"interface_file": false,
"source_file": "Rewrite.Monoid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.Monoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | x: a -> x == x | Prims.Tot | [
"total"
]
| []
| [
"FStar.Squash.return_squash",
"Prims.equals",
"Prims.Refl",
"Prims.eq2"
]
| []
| false | false | false | false | false | let refl (#a: Type) (x: a) : (x == x) =
| FStar.Squash.return_squash Refl | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divides_sub | val divides_sub (a b d:int) : Lemma
(requires d `divides` a /\ d `divides` b)
(ensures d `divides` (a - b)) | val divides_sub (a b d:int) : Lemma
(requires d `divides` a /\ d `divides` b)
(ensures d `divides` (a - b)) | let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 85,
"start_col": 0,
"start_line": 83
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> d: Prims.int
-> FStar.Pervasives.Lemma
(requires FStar.Math.Euclid.divides d a /\ FStar.Math.Euclid.divides d b)
(ensures FStar.Math.Euclid.divides d (a - b)) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Math.Euclid.divides_plus",
"Prims.op_Minus",
"Prims.unit",
"FStar.Classical.forall_intro_2",
"Prims.l_imp",
"FStar.Math.Euclid.divides",
"FStar.Classical.move_requires_2",
"FStar.Math.Euclid.divides_minus"
]
| []
| false | false | true | false | false | let divides_sub a b d =
| Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (- b) d | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divides_minus | val divides_minus (a b:int) : Lemma
(requires a `divides` b)
(ensures a `divides` (-b)) | val divides_minus (a b:int) : Lemma
(requires a `divides` b)
(ensures a `divides` (-b)) | let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q)) | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 66,
"end_line": 67,
"start_col": 0,
"start_line": 64
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int
-> FStar.Pervasives.Lemma (requires FStar.Math.Euclid.divides a b)
(ensures FStar.Math.Euclid.divides a (- b)) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Classical.exists_elim",
"FStar.Math.Euclid.divides",
"Prims.op_Minus",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Mul.op_Star",
"FStar.Squash.get_proof",
"FStar.Classical.exists_intro",
"Prims.squash",
"Prims.unit"
]
| []
| false | false | true | false | false | let divides_minus a b =
| Classical.exists_elim (a `divides` (- b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> - b = q' * a) (- q)) | false |
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.four_to_two_two | val four_to_two_two (#a: Type) (x: four a) : two (two a) | val four_to_two_two (#a: Type) (x: four a) : two (two a) | let four_to_two_two (#a:Type) (x:four a) : two (two a) =
let Mkfour x0 x1 x2 x3 = x in
Mktwo (Mktwo x0 x1) (Mktwo x2 x3) | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 20,
"start_col": 0,
"start_line": 18
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul
unfold let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3)
unfold let four_map2 (#a #b:Type) (f:a -> a -> b) (x y:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3)
let two_two_to_four (#a:Type) (x:two (two a)) : four a =
let (Mktwo (Mktwo x0 x1) (Mktwo x2 x3)) = x in
Mkfour x0 x1 x2 x3 | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | x: Vale.Def.Words_s.four a -> Vale.Def.Words_s.two (Vale.Def.Words_s.two a) | Prims.Tot | [
"total"
]
| []
| [
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.Mktwo",
"Vale.Def.Words_s.two"
]
| []
| false | false | false | true | false | let four_to_two_two (#a: Type) (x: four a) : two (two a) =
| let Mkfour x0 x1 x2 x3 = x in
Mktwo (Mktwo x0 x1) (Mktwo x2 x3) | false |
FStar.Math.Euclid.fst | FStar.Math.Euclid.divides_opp | val divides_opp (a b:int) : Lemma
(requires a `divides` b)
(ensures (-a) `divides` b) | val divides_opp (a b:int) : Lemma
(requires a `divides` b)
(ensures (-a) `divides` b) | let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q)) | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 68,
"end_line": 72,
"start_col": 0,
"start_line": 69
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int
-> FStar.Pervasives.Lemma (requires FStar.Math.Euclid.divides a b)
(ensures FStar.Math.Euclid.divides (- a) b) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Classical.exists_elim",
"FStar.Math.Euclid.divides",
"Prims.op_Minus",
"Prims.b2t",
"Prims.op_Equality",
"FStar.Mul.op_Star",
"FStar.Squash.get_proof",
"FStar.Classical.exists_intro",
"Prims.squash",
"Prims.unit"
]
| []
| false | false | true | false | false | let divides_opp a b =
| Classical.exists_elim ((- a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (- a)) (- q)) | false |
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.four_reverse | val four_reverse (#a: Type) (x: four a) : four a | val four_reverse (#a: Type) (x: four a) : four a | let four_reverse (#a:Type) (x:four a) : four a =
let Mkfour x0 x1 x2 x3 = x in
Mkfour x3 x2 x1 x0 | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 20,
"end_line": 63,
"start_col": 0,
"start_line": 61
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul
unfold let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3)
unfold let four_map2 (#a #b:Type) (f:a -> a -> b) (x y:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3)
let two_two_to_four (#a:Type) (x:two (two a)) : four a =
let (Mktwo (Mktwo x0 x1) (Mktwo x2 x3)) = x in
Mkfour x0 x1 x2 x3
let four_to_two_two (#a:Type) (x:four a) : two (two a) =
let Mkfour x0 x1 x2 x3 = x in
Mktwo (Mktwo x0 x1) (Mktwo x2 x3)
unfold
let nat_to_four_unfold (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
Mkfour (n % n1) ((n / n1) % n1) ((n / n2) % n1) ((n / n3) % n1)
[@"opaque_to_smt"]
let nat_to_four (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
nat_to_four_unfold size n
unfold
let four_to_nat_unfold (size:nat) (x:four (natN (pow2 size))) : natN (pow2 (4 * size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
let Mkfour x0 x1 x2 x3 = x in
int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)
[@"opaque_to_smt"]
let four_to_nat (size:nat) (x:four (natN (pow2 size))) : natN (pow2 (4 * size)) =
four_to_nat_unfold size x
let four_select (#a:Type) (x:four a) (selector:nat2) : a =
match selector with
| 0 -> x.lo0
| 1 -> x.lo1
| 2 -> x.hi2
| 3 -> x.hi3
let four_insert (#a:Type) (x:four a) (y:a) (selector:nat2) : four a =
match selector with
| 0 -> Mkfour y x.lo1 x.hi2 x.hi3
| 1 -> Mkfour x.lo0 y x.hi2 x.hi3
| 2 -> Mkfour x.lo0 x.lo1 y x.hi3
| 3 -> Mkfour x.lo0 x.lo1 x.hi2 y | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | x: Vale.Def.Words_s.four a -> Vale.Def.Words_s.four a | Prims.Tot | [
"total"
]
| []
| [
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.Mkfour"
]
| []
| false | false | false | true | false | let four_reverse (#a: Type) (x: four a) : four a =
| let Mkfour x0 x1 x2 x3 = x in
Mkfour x3 x2 x1 x0 | false |
Rewrite.Monoid.fst | Rewrite.Monoid.test | val test : a: Prims.int -> b: Prims.int -> p: Type0 -> Prims.unit | let test (a b : int) (p:Type) =
assert ((((a + b + 0) == (a + b)) ==> p) ==> p)
by (norm [];
rewrite_int true;
apply_imp (implies_intro());
norm [delta; zeta;iota; primops];
apply (`refl)) | {
"file_name": "examples/tactics/Rewrite.Monoid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 94,
"start_col": 0,
"start_line": 88
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Rewrite.Monoid
open FStar.Algebra.Monoid
open FStar.List
open FStar.Reflection.V2
open FStar.Tactics.V2
open FStar.Tactics.CanonMonoid
let is_reifiable (m_mult:term) (m_unit:term) (me:term) : Tac bool =
let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
// if unify (pack (Tv_FVar fv)) (quote (Monoid?.mult m)) then -- doesn't work
let t1 = norm_term [delta;zeta;iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ ->
term_eq (norm_term [delta;zeta;iota] me) m_unit
let aux (#a:Type) (#rhs:a) (#lhs:a) (_:squash (lhs == rhs)) : Lemma (lhs == rhs) = ()
let monoid_reflect_rhs (a:Type) (m:monoid a) (rhs:exp a) (lhs:a)
(_ : squash (lhs == mdenote m rhs))
: Lemma (lhs == mldenote m (flatten rhs)) =
flatten_correct m rhs
let replace_point (#a:Type) (m:monoid a) (rhs:exp a) =
focus (fun () ->
let t =
mk_app (`monoid_reflect_rhs)
[(quote a, Q_Explicit);
(quote m, Q_Explicit);
(quote rhs, Q_Explicit)] in
(* dump "before replace point"; *)
apply_lemma t;
(* dump "after replace point"; *)
norm [delta;primops;zeta;iota];
(* dump "after replace norm"; *)
trefl ())
let should_rewrite (#a:Type) (m:monoid a) (everywhere:bool) (t:term) : Tac (bool * int) =
let m_mult = norm_term [delta;zeta;iota] (quote (Monoid?.mult m)) in
let m_unit = norm_term [delta;zeta;iota] (quote (Monoid?.unit m)) in
// debug "should_rewrite: ";
// debug (term_to_string t);
if is_reifiable m_mult m_unit t
then true, (if everywhere then 1 else 2)
else false, 0
let rewrite_monoid (#a:Type) (m:monoid a) () : Tac unit =
norm [zeta;iota];
let g = cur_goal () in
match term_as_formula g with
| Comp (Eq (Some t)) lhs _ ->
debug (term_to_string g);
if term_eq t (quote a) then
// let _ = dump "Trying canon ... " in
let lhs_exp : exp a = reification m lhs in
replace_point m lhs_exp
// dump "change"
else trefl ()
| _ ->
fail "Unexpected goal to rewriter"
let rewrite_int (everywhere:bool) =
topdown_rewrite
(should_rewrite int_plus_monoid everywhere)
(rewrite_monoid int_plus_monoid)
let elim_implies #p #q (_:(p ==> q)) (_:p) : squash q = ()
let apply_imp (h:binding) =
mapply (mk_app (`elim_implies) [(pack (Tv_Var (binding_to_namedv h)), Q_Explicit)]) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonMonoid.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked",
"FStar.Algebra.Monoid.fst.checked"
],
"interface_file": false,
"source_file": "Rewrite.Monoid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.Monoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Prims.int -> b: Prims.int -> p: Type0 -> Prims.unit | Prims.Tot | [
"total"
]
| []
| [
"Prims.int",
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.l_imp",
"Prims.eq2",
"Prims.op_Addition",
"Prims.unit",
"FStar.Tactics.V2.Derived.apply",
"FStar.Stubs.Tactics.V2.Builtins.norm",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta",
"FStar.Pervasives.zeta",
"FStar.Pervasives.iota",
"FStar.Pervasives.primops",
"Prims.Nil",
"Rewrite.Monoid.apply_imp",
"FStar.Tactics.NamedView.binding",
"FStar.Tactics.V2.Logic.implies_intro",
"Rewrite.Monoid.rewrite_int"
]
| []
| false | false | false | true | false | let test (a b: int) (p: Type) =
| FStar.Tactics.Effect.assert_by_tactic ((((a + b + 0) == (a + b)) ==> p) ==> p)
(fun _ ->
();
(norm [];
rewrite_int true;
apply_imp (implies_intro ());
norm [delta; zeta; iota; primops];
apply (`refl))) | false |
|
FStar.DM4F.IntStoreFixed.fst | FStar.DM4F.IntStoreFixed.iget | val iget: Prims.unit -> int_store heap | val iget: Prims.unit -> int_store heap | let iget () : int_store heap = fun store -> store, store | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixed.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 56,
"end_line": 28,
"start_col": 0,
"start_line": 28
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixed
open FStar.DM4F.Heap.IntStoreFixed
(* TODO : Try to use [either a exn] instead of [option] *)
type int_store (a:Type) = heap -> M (a * heap)
let return_is (a:Type) (x:a) : int_store a = fun store -> x, store
let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b =
fun store ->
let (z, store') = x store in
f z store' | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixedReader.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixed.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | _: Prims.unit -> FStar.DM4F.IntStoreFixed.int_store FStar.DM4F.Heap.IntStoreFixed.heap | Prims.Tot | [
"total"
]
| []
| [
"Prims.unit",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"FStar.DM4F.IntStoreFixed.int_store"
]
| []
| false | false | false | true | false | let iget () : int_store heap =
| fun store -> store, store | false |
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.four_to_nat_unfold | val four_to_nat_unfold (size: nat) (x: four (natN (pow2 size))) : natN (pow2 (4 * size)) | val four_to_nat_unfold (size: nat) (x: four (natN (pow2 size))) : natN (pow2 (4 * size)) | let four_to_nat_unfold (size:nat) (x:four (natN (pow2 size))) : natN (pow2 (4 * size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
let Mkfour x0 x1 x2 x3 = x in
int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3) | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 51,
"end_line": 41,
"start_col": 0,
"start_line": 35
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul
unfold let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3)
unfold let four_map2 (#a #b:Type) (f:a -> a -> b) (x y:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3)
let two_two_to_four (#a:Type) (x:two (two a)) : four a =
let (Mktwo (Mktwo x0 x1) (Mktwo x2 x3)) = x in
Mkfour x0 x1 x2 x3
let four_to_two_two (#a:Type) (x:four a) : two (two a) =
let Mkfour x0 x1 x2 x3 = x in
Mktwo (Mktwo x0 x1) (Mktwo x2 x3)
unfold
let nat_to_four_unfold (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
Mkfour (n % n1) ((n / n1) % n1) ((n / n2) % n1) ((n / n3) % n1)
[@"opaque_to_smt"]
let nat_to_four (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
nat_to_four_unfold size n | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | size: Prims.nat -> x: Vale.Def.Words_s.four (Vale.Def.Words_s.natN (Prims.pow2 size))
-> Vale.Def.Words_s.natN (Prims.pow2 (4 * size)) | Prims.Tot | [
"total"
]
| []
| [
"Prims.nat",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words_s.int_to_natN",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"Prims.pos",
"Vale.Def.Words_s.pow2_norm"
]
| []
| false | false | false | false | false | let four_to_nat_unfold (size: nat) (x: four (natN (pow2 size))) : natN (pow2 (4 * size)) =
| let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
let Mkfour x0 x1 x2 x3 = x in
int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3) | false |
FStar.DM4F.IntStoreFixed.fst | FStar.DM4F.IntStoreFixed.return_is | val return_is (a: Type) (x: a) : int_store a | val return_is (a: Type) (x: a) : int_store a | let return_is (a:Type) (x:a) : int_store a = fun store -> x, store | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixed.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 66,
"end_line": 22,
"start_col": 0,
"start_line": 22
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixed
open FStar.DM4F.Heap.IntStoreFixed
(* TODO : Try to use [either a exn] instead of [option] *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixedReader.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixed.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Type -> x: a -> FStar.DM4F.IntStoreFixed.int_store a | Prims.Tot | [
"total"
]
| []
| [
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"FStar.DM4F.IntStoreFixed.int_store"
]
| []
| false | false | false | true | false | let return_is (a: Type) (x: a) : int_store a =
| fun store -> x, store | false |
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.four_insert | val four_insert (#a: Type) (x: four a) (y: a) (selector: nat2) : four a | val four_insert (#a: Type) (x: four a) (y: a) (selector: nat2) : four a | let four_insert (#a:Type) (x:four a) (y:a) (selector:nat2) : four a =
match selector with
| 0 -> Mkfour y x.lo1 x.hi2 x.hi3
| 1 -> Mkfour x.lo0 y x.hi2 x.hi3
| 2 -> Mkfour x.lo0 x.lo1 y x.hi3
| 3 -> Mkfour x.lo0 x.lo1 x.hi2 y | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 35,
"end_line": 59,
"start_col": 0,
"start_line": 54
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul
unfold let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3)
unfold let four_map2 (#a #b:Type) (f:a -> a -> b) (x y:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3)
let two_two_to_four (#a:Type) (x:two (two a)) : four a =
let (Mktwo (Mktwo x0 x1) (Mktwo x2 x3)) = x in
Mkfour x0 x1 x2 x3
let four_to_two_two (#a:Type) (x:four a) : two (two a) =
let Mkfour x0 x1 x2 x3 = x in
Mktwo (Mktwo x0 x1) (Mktwo x2 x3)
unfold
let nat_to_four_unfold (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
Mkfour (n % n1) ((n / n1) % n1) ((n / n2) % n1) ((n / n3) % n1)
[@"opaque_to_smt"]
let nat_to_four (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
nat_to_four_unfold size n
unfold
let four_to_nat_unfold (size:nat) (x:four (natN (pow2 size))) : natN (pow2 (4 * size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
let Mkfour x0 x1 x2 x3 = x in
int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)
[@"opaque_to_smt"]
let four_to_nat (size:nat) (x:four (natN (pow2 size))) : natN (pow2 (4 * size)) =
four_to_nat_unfold size x
let four_select (#a:Type) (x:four a) (selector:nat2) : a =
match selector with
| 0 -> x.lo0
| 1 -> x.lo1
| 2 -> x.hi2
| 3 -> x.hi3 | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | x: Vale.Def.Words_s.four a -> y: a -> selector: Vale.Def.Words_s.nat2 -> Vale.Def.Words_s.four a | Prims.Tot | [
"total"
]
| []
| [
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat2",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0"
]
| []
| false | false | false | true | false | let four_insert (#a: Type) (x: four a) (y: a) (selector: nat2) : four a =
| match selector with
| 0 -> Mkfour y x.lo1 x.hi2 x.hi3
| 1 -> Mkfour x.lo0 y x.hi2 x.hi3
| 2 -> Mkfour x.lo0 x.lo1 y x.hi3
| 3 -> Mkfour x.lo0 x.lo1 x.hi2 y | false |
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.four_to_nat | val four_to_nat (size: nat) (x: four (natN (pow2 size))) : natN (pow2 (4 * size)) | val four_to_nat (size: nat) (x: four (natN (pow2 size))) : natN (pow2 (4 * size)) | let four_to_nat (size:nat) (x:four (natN (pow2 size))) : natN (pow2 (4 * size)) =
four_to_nat_unfold size x | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 45,
"start_col": 0,
"start_line": 44
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul
unfold let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3)
unfold let four_map2 (#a #b:Type) (f:a -> a -> b) (x y:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3)
let two_two_to_four (#a:Type) (x:two (two a)) : four a =
let (Mktwo (Mktwo x0 x1) (Mktwo x2 x3)) = x in
Mkfour x0 x1 x2 x3
let four_to_two_two (#a:Type) (x:four a) : two (two a) =
let Mkfour x0 x1 x2 x3 = x in
Mktwo (Mktwo x0 x1) (Mktwo x2 x3)
unfold
let nat_to_four_unfold (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
Mkfour (n % n1) ((n / n1) % n1) ((n / n2) % n1) ((n / n3) % n1)
[@"opaque_to_smt"]
let nat_to_four (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
nat_to_four_unfold size n
unfold
let four_to_nat_unfold (size:nat) (x:four (natN (pow2 size))) : natN (pow2 (4 * size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
let Mkfour x0 x1 x2 x3 = x in
int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | size: Prims.nat -> x: Vale.Def.Words_s.four (Vale.Def.Words_s.natN (Prims.pow2 size))
-> Vale.Def.Words_s.natN (Prims.pow2 (4 * size)) | Prims.Tot | [
"total"
]
| []
| [
"Prims.nat",
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"Vale.Def.Words.Four_s.four_to_nat_unfold",
"FStar.Mul.op_Star"
]
| []
| false | false | false | false | false | let four_to_nat (size: nat) (x: four (natN (pow2 size))) : natN (pow2 (4 * size)) =
| four_to_nat_unfold size x | false |
FStar.DM4F.IntStoreFixed.fst | FStar.DM4F.IntStoreFixed.pre | val pre : Type | let pre = INT_STORE?.pre | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixed.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 24,
"end_line": 54,
"start_col": 0,
"start_line": 54
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixed
open FStar.DM4F.Heap.IntStoreFixed
(* TODO : Try to use [either a exn] instead of [option] *)
type int_store (a:Type) = heap -> M (a * heap)
let return_is (a:Type) (x:a) : int_store a = fun store -> x, store
let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b =
fun store ->
let (z, store') = x store in
f z store'
let iget () : int_store heap = fun store -> store, store
let iput s : int_store unit = fun _ -> (), s
total reifiable reflectable new_effect {
INT_STORE : a:Type -> Effect
with repr = int_store
; bind = bind_is
; return = return_is
; get = iget
; put = iput
}
let get = INT_STORE?.get
let put = INT_STORE?.put
effect IntStore (a:Type) (pre:INT_STORE?.pre) (post: heap -> a -> heap -> GTot Type0) =
INT_STORE a (fun l0 p -> pre l0 /\ (forall x l1. pre l0 /\ post l0 x l1 ==> p (x, l1)))
effect IS (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a). p (x, l0))
effect ISNull (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a * heap). p x)
(* TODO : having a in Type *and* induces a Failure("Universe variable not found") *)
(* whenever we try to normalize-reify it (see below in xxx for instance) *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixedReader.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixed.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | Type | Prims.Tot | [
"total"
]
| []
| [
"FStar.DM4F.IntStoreFixed._dm4f_INT_STORE_pre"
]
| []
| false | false | false | true | true | let pre =
| INT_STORE?.pre | false |
|
FStar.DM4F.IntStoreFixed.fst | FStar.DM4F.IntStoreFixed.bind_is | val bind_is (a b: Type) (x: int_store a) (f: (a -> int_store b)) : int_store b | val bind_is (a b: Type) (x: int_store a) (f: (a -> int_store b)) : int_store b | let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b =
fun store ->
let (z, store') = x store in
f z store' | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixed.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 26,
"start_col": 0,
"start_line": 23
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixed
open FStar.DM4F.Heap.IntStoreFixed
(* TODO : Try to use [either a exn] instead of [option] *)
type int_store (a:Type) = heap -> M (a * heap) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixedReader.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixed.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
a: Type ->
b: Type ->
x: FStar.DM4F.IntStoreFixed.int_store a ->
f: (_: a -> FStar.DM4F.IntStoreFixed.int_store b)
-> FStar.DM4F.IntStoreFixed.int_store b | Prims.Tot | [
"total"
]
| []
| [
"FStar.DM4F.IntStoreFixed.int_store",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.Pervasives.Native.tuple2"
]
| []
| false | false | false | true | false | let bind_is (a b: Type) (x: int_store a) (f: (a -> int_store b)) : int_store b =
| fun store ->
let z, store' = x store in
f z store' | false |
Rewrite.Monoid.fst | Rewrite.Monoid.monoid_reflect_rhs | val monoid_reflect_rhs:
a: Type ->
m: monoid a ->
rhs: exp a ->
lhs: a ->
squash (lhs == mdenote m rhs)
-> Lemma (lhs == mldenote m (flatten rhs)) | val monoid_reflect_rhs:
a: Type ->
m: monoid a ->
rhs: exp a ->
lhs: a ->
squash (lhs == mdenote m rhs)
-> Lemma (lhs == mldenote m (flatten rhs)) | let monoid_reflect_rhs (a:Type) (m:monoid a) (rhs:exp a) (lhs:a)
(_ : squash (lhs == mdenote m rhs))
: Lemma (lhs == mldenote m (flatten rhs)) =
flatten_correct m rhs | {
"file_name": "examples/tactics/Rewrite.Monoid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 39,
"start_col": 0,
"start_line": 36
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module Rewrite.Monoid
open FStar.Algebra.Monoid
open FStar.List
open FStar.Reflection.V2
open FStar.Tactics.V2
open FStar.Tactics.CanonMonoid
let is_reifiable (m_mult:term) (m_unit:term) (me:term) : Tac bool =
let hd, tl = collect_app_ref me in
match inspect hd with
| Tv_FVar fv ->
// if unify (pack (Tv_FVar fv)) (quote (Monoid?.mult m)) then -- doesn't work
let t1 = norm_term [delta;zeta;iota] (pack (Tv_FVar fv)) in
term_eq t1 m_mult
| _ ->
term_eq (norm_term [delta;zeta;iota] me) m_unit
let aux (#a:Type) (#rhs:a) (#lhs:a) (_:squash (lhs == rhs)) : Lemma (lhs == rhs) = () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.CanonMonoid.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.fst.checked",
"FStar.Algebra.Monoid.fst.checked"
],
"interface_file": false,
"source_file": "Rewrite.Monoid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.CanonMonoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Reflection.V2",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Algebra.Monoid",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "Rewrite",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
a: Type ->
m: FStar.Algebra.Monoid.monoid a ->
rhs: FStar.Tactics.CanonMonoid.exp a ->
lhs: a ->
_: Prims.squash (lhs == FStar.Tactics.CanonMonoid.mdenote m rhs)
-> FStar.Pervasives.Lemma
(ensures lhs == FStar.Tactics.CanonMonoid.mldenote m (FStar.Tactics.CanonMonoid.flatten rhs)) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"FStar.Algebra.Monoid.monoid",
"FStar.Tactics.CanonMonoid.exp",
"Prims.squash",
"Prims.eq2",
"FStar.Tactics.CanonMonoid.mdenote",
"FStar.Tactics.CanonMonoid.flatten_correct",
"Prims.unit",
"Prims.l_True",
"FStar.Tactics.CanonMonoid.mldenote",
"FStar.Tactics.CanonMonoid.flatten",
"Prims.Nil",
"FStar.Pervasives.pattern"
]
| []
| true | false | true | false | false | let monoid_reflect_rhs
(a: Type)
(m: monoid a)
(rhs: exp a)
(lhs: a)
(_: squash (lhs == mdenote m rhs))
: Lemma (lhs == mldenote m (flatten rhs)) =
| flatten_correct m rhs | false |
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.nat_to_four | val nat_to_four (size: nat) (n: natN (pow2 (4 * size))) : four (natN (pow2 size)) | val nat_to_four (size: nat) (n: natN (pow2 (4 * size))) : four (natN (pow2 size)) | let nat_to_four (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
nat_to_four_unfold size n | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 32,
"start_col": 0,
"start_line": 31
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul
unfold let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3)
unfold let four_map2 (#a #b:Type) (f:a -> a -> b) (x y:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3)
let two_two_to_four (#a:Type) (x:two (two a)) : four a =
let (Mktwo (Mktwo x0 x1) (Mktwo x2 x3)) = x in
Mkfour x0 x1 x2 x3
let four_to_two_two (#a:Type) (x:four a) : two (two a) =
let Mkfour x0 x1 x2 x3 = x in
Mktwo (Mktwo x0 x1) (Mktwo x2 x3)
unfold
let nat_to_four_unfold (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
Mkfour (n % n1) ((n / n1) % n1) ((n / n2) % n1) ((n / n3) % n1) | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | size: Prims.nat -> n: Vale.Def.Words_s.natN (Prims.pow2 (4 * size))
-> Vale.Def.Words_s.four (Vale.Def.Words_s.natN (Prims.pow2 size)) | Prims.Tot | [
"total"
]
| []
| [
"Prims.nat",
"Vale.Def.Words_s.natN",
"Prims.pow2",
"FStar.Mul.op_Star",
"Vale.Def.Words.Four_s.nat_to_four_unfold",
"Vale.Def.Words_s.four"
]
| []
| false | false | false | false | false | let nat_to_four (size: nat) (n: natN (pow2 (4 * size))) : four (natN (pow2 size)) =
| nat_to_four_unfold size n | false |
FStar.DM4F.IntStoreFixed.fst | FStar.DM4F.IntStoreFixed.post | val post : a: Type -> Type | let post = INT_STORE?.post | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixed.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 55,
"start_col": 0,
"start_line": 55
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixed
open FStar.DM4F.Heap.IntStoreFixed
(* TODO : Try to use [either a exn] instead of [option] *)
type int_store (a:Type) = heap -> M (a * heap)
let return_is (a:Type) (x:a) : int_store a = fun store -> x, store
let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b =
fun store ->
let (z, store') = x store in
f z store'
let iget () : int_store heap = fun store -> store, store
let iput s : int_store unit = fun _ -> (), s
total reifiable reflectable new_effect {
INT_STORE : a:Type -> Effect
with repr = int_store
; bind = bind_is
; return = return_is
; get = iget
; put = iput
}
let get = INT_STORE?.get
let put = INT_STORE?.put
effect IntStore (a:Type) (pre:INT_STORE?.pre) (post: heap -> a -> heap -> GTot Type0) =
INT_STORE a (fun l0 p -> pre l0 /\ (forall x l1. pre l0 /\ post l0 x l1 ==> p (x, l1)))
effect IS (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a). p (x, l0))
effect ISNull (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a * heap). p x)
(* TODO : having a in Type *and* induces a Failure("Universe variable not found") *)
(* whenever we try to normalize-reify it (see below in xxx for instance) *)
let wp = INT_STORE?.wp | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixedReader.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixed.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Type -> Type | Prims.Tot | [
"total"
]
| []
| [
"FStar.DM4F.IntStoreFixed._dm4f_INT_STORE_post"
]
| []
| false | false | false | true | true | let post =
| INT_STORE?.post | false |
|
FStar.DM4F.IntStoreFixed.fst | FStar.DM4F.IntStoreFixed.wp | val wp : a: Type -> Type | let wp = INT_STORE?.wp | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixed.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 22,
"end_line": 53,
"start_col": 0,
"start_line": 53
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixed
open FStar.DM4F.Heap.IntStoreFixed
(* TODO : Try to use [either a exn] instead of [option] *)
type int_store (a:Type) = heap -> M (a * heap)
let return_is (a:Type) (x:a) : int_store a = fun store -> x, store
let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b =
fun store ->
let (z, store') = x store in
f z store'
let iget () : int_store heap = fun store -> store, store
let iput s : int_store unit = fun _ -> (), s
total reifiable reflectable new_effect {
INT_STORE : a:Type -> Effect
with repr = int_store
; bind = bind_is
; return = return_is
; get = iget
; put = iput
}
let get = INT_STORE?.get
let put = INT_STORE?.put
effect IntStore (a:Type) (pre:INT_STORE?.pre) (post: heap -> a -> heap -> GTot Type0) =
INT_STORE a (fun l0 p -> pre l0 /\ (forall x l1. pre l0 /\ post l0 x l1 ==> p (x, l1)))
effect IS (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a). p (x, l0))
effect ISNull (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a * heap). p x)
(* TODO : having a in Type *and* induces a Failure("Universe variable not found") *)
(* whenever we try to normalize-reify it (see below in xxx for instance) *) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixedReader.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixed.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Type -> Type | Prims.Tot | [
"total"
]
| []
| [
"FStar.DM4F.IntStoreFixed._dm4f_INT_STORE_wp"
]
| []
| false | false | false | true | true | let wp =
| INT_STORE?.wp | false |
|
FStar.Math.Euclid.fst | FStar.Math.Euclid.bezout_prime | val bezout_prime (p:int) (a:pos{a < p}) : Pure (int & int)
(requires is_prime p)
(ensures fun (r, s) -> r * p + s * a = 1) | val bezout_prime (p:int) (a:pos{a < p}) : Pure (int & int)
(requires is_prime p)
(ensures fun (r, s) -> r * p + s * a = 1) | let bezout_prime p a =
let r, s, d = euclid_gcd p a in
assert (r * p + s * a = d);
assert (is_gcd p a d);
is_gcd_prime p a;
is_gcd_unique p a 1 d;
assert (d = 1 \/ d = -1);
assert ((-r) * p + (-s) * a == -(r * p + s * a)) by (FStar.Tactics.Canon.canon());
if d = 1 then r, s else -r, -s | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 218,
"start_col": 0,
"start_line": 210
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
///
let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b)
let divides_mod a b =
Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a))
(fun q -> cancel_mul_div q b)
let is_gcd_unique a b c d =
divide_antisym c d
let is_gcd_reflexive a = ()
let is_gcd_symmetric a b d = ()
let is_gcd_0 a = ()
let is_gcd_1 a = ()
let is_gcd_minus a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
opp_idempotent b
let is_gcd_opp a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_opp d a;
divides_opp d b
let is_gcd_plus a b q d =
add_sub_r b (q * a);
Classical.forall_intro_3 (Classical.move_requires_3 divides_plus);
Classical.forall_intro_3 (Classical.move_requires_3 divides_mult_right);
Classical.forall_intro_3 (Classical.move_requires_3 divides_sub)
///
/// Extended Euclidean algorithm
///
val is_gcd_for_euclid (a b q d:int) : Lemma
(requires is_gcd b (a - q * b) d)
(ensures is_gcd a b d)
let is_gcd_for_euclid a b q d =
add_sub_l a (q * b);
is_gcd_plus b (a - q * b) q d
val egcd (a b u1 u2 u3 v1 v2 v3:int) : Pure (int & int & int)
(requires v3 >= 0 /\
u1 * a + u2 * b = u3 /\
v1 * a + v2 * b = v3 /\
(forall d. is_gcd u3 v3 d ==> is_gcd a b d))
(ensures (fun (u, v, d) -> u * a + v * b = d /\ is_gcd a b d))
(decreases v3)
let rec egcd a b u1 u2 u3 v1 v2 v3 =
if v3 = 0 then
begin
divides_0 u3;
(u1, u2, u3)
end
else
begin
let q = u3 / v3 in
euclidean_division_definition u3 v3;
assert (u3 - q * v3 = (q * v3 + u3 % v3) - q * v3);
assert (q * v3 - q * v3 = 0);
swap_add_plus_minus (q * v3) (u3 % v3) (q * v3);
calc (==) {
(u1 - q * v1) * a + (u2 - q * v2) * b;
== { _ by (FStar.Tactics.Canon.canon()) }
(u1 * a + u2 * b) - q * (v1 * a + v2 * b);
== { }
u3 - q * v3;
== { lemma_div_mod u3 v3 }
u3 % v3;
};
let u1, v1 = v1, u1 - q * v1 in
let u2, v2 = v2, u2 - q * v2 in
let u3' = u3 in
let v3' = v3 in
let u3, v3 = v3, u3 - q * v3 in
(* proving the implication in the precondition *)
introduce forall d. is_gcd v3' (u3' - q * v3') d ==> is_gcd u3' v3' d with
introduce _ ==> _ with _.
is_gcd_for_euclid u3' v3' q d;
let r = egcd a b u1 u2 u3 v1 v2 v3 in
r
end
let euclid_gcd a b =
if b >= 0 then
egcd a b 1 0 a 0 1 b
else (
introduce forall d. is_gcd a (-b) d ==> is_gcd a b d
with introduce _ ==> _
with _pf.
(is_gcd_minus a b d;
is_gcd_symmetric b a d);
let res = egcd a b 1 0 a 0 (-1) (-b) in
let _, _, d = res in
assert (is_gcd a b d);
res
)
val is_gcd_prime_aux (p:int) (a:pos{a < p}) (d:int) : Lemma
(requires is_prime p /\ d `divides` p /\ d `divides` a)
(ensures d = 1 \/ d = -1)
let is_gcd_prime_aux p a d = ()
val is_gcd_prime (p:int{is_prime p}) (a:pos{a < p}) : Lemma (is_gcd p a 1)
let is_gcd_prime p a =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
Classical.forall_intro (Classical.move_requires (is_gcd_prime_aux p a));
assert (forall x. x `divides` p /\ x `divides` a ==> x = 1 \/ x = -1 /\ x `divides` 1) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: Prims.int -> a: Prims.pos{a < p} -> Prims.Pure (Prims.int * Prims.int) | Prims.Pure | []
| []
| [
"Prims.int",
"Prims.pos",
"Prims.b2t",
"Prims.op_LessThan",
"Prims.op_Equality",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Prims.op_Minus",
"FStar.Pervasives.Native.tuple2",
"Prims.unit",
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"FStar.Tactics.Canon.canon",
"Prims._assert",
"Prims.l_or",
"FStar.Math.Euclid.is_gcd_unique",
"FStar.Math.Euclid.is_gcd_prime",
"FStar.Math.Euclid.is_gcd",
"FStar.Pervasives.Native.tuple3",
"FStar.Math.Euclid.euclid_gcd"
]
| []
| false | false | false | false | false | let bezout_prime p a =
| let r, s, d = euclid_gcd p a in
assert (r * p + s * a = d);
assert (is_gcd p a d);
is_gcd_prime p a;
is_gcd_unique p a 1 d;
assert (d = 1 \/ d = - 1);
FStar.Tactics.Effect.assert_by_tactic ((- r) * p + (- s) * a == - (r * p + s * a))
(fun _ ->
();
(FStar.Tactics.Canon.canon ()));
if d = 1 then r, s else - r, - s | false |
FStar.DM4F.IntStoreFixed.fst | FStar.DM4F.IntStoreFixed.repr | val repr : a: Type ->
wp_a:
(
_: FStar.DM4F.Heap.IntStoreFixed.heap ->
_: (_: (a * FStar.DM4F.Heap.IntStoreFixed.heap) -> Type0)
-> Type0)
-> Type | let repr = INT_STORE?.repr | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixed.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 26,
"end_line": 56,
"start_col": 0,
"start_line": 56
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixed
open FStar.DM4F.Heap.IntStoreFixed
(* TODO : Try to use [either a exn] instead of [option] *)
type int_store (a:Type) = heap -> M (a * heap)
let return_is (a:Type) (x:a) : int_store a = fun store -> x, store
let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b =
fun store ->
let (z, store') = x store in
f z store'
let iget () : int_store heap = fun store -> store, store
let iput s : int_store unit = fun _ -> (), s
total reifiable reflectable new_effect {
INT_STORE : a:Type -> Effect
with repr = int_store
; bind = bind_is
; return = return_is
; get = iget
; put = iput
}
let get = INT_STORE?.get
let put = INT_STORE?.put
effect IntStore (a:Type) (pre:INT_STORE?.pre) (post: heap -> a -> heap -> GTot Type0) =
INT_STORE a (fun l0 p -> pre l0 /\ (forall x l1. pre l0 /\ post l0 x l1 ==> p (x, l1)))
effect IS (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a). p (x, l0))
effect ISNull (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a * heap). p x)
(* TODO : having a in Type *and* induces a Failure("Universe variable not found") *)
(* whenever we try to normalize-reify it (see below in xxx for instance) *)
let wp = INT_STORE?.wp
let pre = INT_STORE?.pre | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixedReader.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixed.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
a: Type ->
wp_a:
(
_: FStar.DM4F.Heap.IntStoreFixed.heap ->
_: (_: (a * FStar.DM4F.Heap.IntStoreFixed.heap) -> Type0)
-> Type0)
-> Type | Prims.Tot | [
"total"
]
| []
| [
"FStar.DM4F.IntStoreFixed._dm4f_INT_STORE_repr"
]
| []
| false | false | false | true | true | let repr =
| INT_STORE?.repr | false |
|
FStar.Math.Euclid.fst | FStar.Math.Euclid.euclid_prime | val euclid_prime (p:int{is_prime p}) (a b:int) : Lemma
(requires (a * b) % p = 0)
(ensures a % p = 0 \/ b % p = 0) | val euclid_prime (p:int{is_prime p}) (a b:int) : Lemma
(requires (a * b) % p = 0)
(ensures a % p = 0 \/ b % p = 0) | let euclid_prime p a b =
let ra, sa, da = euclid_gcd p a in
let rb, sb, db = euclid_gcd p b in
assert (is_gcd p a da);
assert (is_gcd p b db);
assert (da `divides` p);
assert (da = 1 \/ da = -1 \/ da = p \/ da = -p);
if da = 1 then
euclid p a b ra sa
else if da = -1 then
begin
assert ((-ra) * p + (-sa) * a == -(ra * p + sa * a)) by (FStar.Tactics.Canon.canon());
euclid p a b (-ra) (-sa)
end
else if da = p then
divides_mod a p
else
begin
opp_idempotent p;
divides_opp (-p) a;
divides_mod a p
end | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 273,
"start_col": 0,
"start_line": 252
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
///
let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b)
let divides_mod a b =
Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a))
(fun q -> cancel_mul_div q b)
let is_gcd_unique a b c d =
divide_antisym c d
let is_gcd_reflexive a = ()
let is_gcd_symmetric a b d = ()
let is_gcd_0 a = ()
let is_gcd_1 a = ()
let is_gcd_minus a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
opp_idempotent b
let is_gcd_opp a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_opp d a;
divides_opp d b
let is_gcd_plus a b q d =
add_sub_r b (q * a);
Classical.forall_intro_3 (Classical.move_requires_3 divides_plus);
Classical.forall_intro_3 (Classical.move_requires_3 divides_mult_right);
Classical.forall_intro_3 (Classical.move_requires_3 divides_sub)
///
/// Extended Euclidean algorithm
///
val is_gcd_for_euclid (a b q d:int) : Lemma
(requires is_gcd b (a - q * b) d)
(ensures is_gcd a b d)
let is_gcd_for_euclid a b q d =
add_sub_l a (q * b);
is_gcd_plus b (a - q * b) q d
val egcd (a b u1 u2 u3 v1 v2 v3:int) : Pure (int & int & int)
(requires v3 >= 0 /\
u1 * a + u2 * b = u3 /\
v1 * a + v2 * b = v3 /\
(forall d. is_gcd u3 v3 d ==> is_gcd a b d))
(ensures (fun (u, v, d) -> u * a + v * b = d /\ is_gcd a b d))
(decreases v3)
let rec egcd a b u1 u2 u3 v1 v2 v3 =
if v3 = 0 then
begin
divides_0 u3;
(u1, u2, u3)
end
else
begin
let q = u3 / v3 in
euclidean_division_definition u3 v3;
assert (u3 - q * v3 = (q * v3 + u3 % v3) - q * v3);
assert (q * v3 - q * v3 = 0);
swap_add_plus_minus (q * v3) (u3 % v3) (q * v3);
calc (==) {
(u1 - q * v1) * a + (u2 - q * v2) * b;
== { _ by (FStar.Tactics.Canon.canon()) }
(u1 * a + u2 * b) - q * (v1 * a + v2 * b);
== { }
u3 - q * v3;
== { lemma_div_mod u3 v3 }
u3 % v3;
};
let u1, v1 = v1, u1 - q * v1 in
let u2, v2 = v2, u2 - q * v2 in
let u3' = u3 in
let v3' = v3 in
let u3, v3 = v3, u3 - q * v3 in
(* proving the implication in the precondition *)
introduce forall d. is_gcd v3' (u3' - q * v3') d ==> is_gcd u3' v3' d with
introduce _ ==> _ with _.
is_gcd_for_euclid u3' v3' q d;
let r = egcd a b u1 u2 u3 v1 v2 v3 in
r
end
let euclid_gcd a b =
if b >= 0 then
egcd a b 1 0 a 0 1 b
else (
introduce forall d. is_gcd a (-b) d ==> is_gcd a b d
with introduce _ ==> _
with _pf.
(is_gcd_minus a b d;
is_gcd_symmetric b a d);
let res = egcd a b 1 0 a 0 (-1) (-b) in
let _, _, d = res in
assert (is_gcd a b d);
res
)
val is_gcd_prime_aux (p:int) (a:pos{a < p}) (d:int) : Lemma
(requires is_prime p /\ d `divides` p /\ d `divides` a)
(ensures d = 1 \/ d = -1)
let is_gcd_prime_aux p a d = ()
val is_gcd_prime (p:int{is_prime p}) (a:pos{a < p}) : Lemma (is_gcd p a 1)
let is_gcd_prime p a =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
Classical.forall_intro (Classical.move_requires (is_gcd_prime_aux p a));
assert (forall x. x `divides` p /\ x `divides` a ==> x = 1 \/ x = -1 /\ x `divides` 1)
let bezout_prime p a =
let r, s, d = euclid_gcd p a in
assert (r * p + s * a = d);
assert (is_gcd p a d);
is_gcd_prime p a;
is_gcd_unique p a 1 d;
assert (d = 1 \/ d = -1);
assert ((-r) * p + (-s) * a == -(r * p + s * a)) by (FStar.Tactics.Canon.canon());
if d = 1 then r, s else -r, -s
let euclid n a b r s =
let open FStar.Math.Lemmas in
calc (==) {
b % n;
== { distributivity_add_left (r * n) (s * a) b }
(r * n * b + s * a * b) % n;
== { paren_mul_right s a b }
(r * n * b + s * (a * b)) % n;
== { modulo_distributivity (r * n * b) (s * (a * b)) n }
((r * n * b) % n + s * (a * b) % n) % n;
== { lemma_mod_mul_distr_r s (a * b) n }
((r * n * b) % n + s * ((a * b) % n) % n) % n;
== { assert (a * b % n = 0) }
((r * n * b) % n + s * 0 % n) % n;
== { assert (s * 0 == 0) }
((r * n * b) % n + 0 % n) % n;
== { modulo_lemma 0 n }
((r * n * b) % n) % n;
== { lemma_mod_twice (r * n * b) n }
(r * n * b) % n;
== { _ by (FStar.Tactics.Canon.canon ()) }
(n * (r * b)) % n;
== { lemma_mod_mul_distr_l n (r * b) n}
n % n * (r * b) % n;
== { assert (n % n = 0) }
(0 * (r * b)) % n;
== { assert (0 * (r * b) == 0) }
0 % n;
== { small_mod 0 n }
0;
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | p: Prims.int{FStar.Math.Euclid.is_prime p} -> a: Prims.int -> b: Prims.int
-> FStar.Pervasives.Lemma (requires a * b % p = 0) (ensures a % p = 0 \/ b % p = 0) | FStar.Pervasives.Lemma | [
"lemma"
]
| []
| [
"Prims.int",
"FStar.Math.Euclid.is_prime",
"Prims.op_Equality",
"FStar.Math.Euclid.euclid",
"Prims.bool",
"Prims.op_Minus",
"Prims.unit",
"FStar.Tactics.Effect.assert_by_tactic",
"Prims.eq2",
"Prims.op_Addition",
"FStar.Mul.op_Star",
"FStar.Tactics.Canon.canon",
"FStar.Math.Euclid.divides_mod",
"FStar.Math.Euclid.divides_opp",
"FStar.Math.Euclid.opp_idempotent",
"Prims._assert",
"Prims.l_or",
"Prims.b2t",
"FStar.Math.Euclid.divides",
"FStar.Math.Euclid.is_gcd",
"FStar.Pervasives.Native.tuple3",
"FStar.Math.Euclid.euclid_gcd"
]
| []
| false | false | true | false | false | let euclid_prime p a b =
| let ra, sa, da = euclid_gcd p a in
let rb, sb, db = euclid_gcd p b in
assert (is_gcd p a da);
assert (is_gcd p b db);
assert (da `divides` p);
assert (da = 1 \/ da = - 1 \/ da = p \/ da = - p);
if da = 1
then euclid p a b ra sa
else
if da = - 1
then
(FStar.Tactics.Effect.assert_by_tactic ((- ra) * p + (- sa) * a == - (ra * p + sa * a))
(fun _ ->
();
(FStar.Tactics.Canon.canon ()));
euclid p a b (- ra) (- sa))
else
if da = p
then divides_mod a p
else
(opp_idempotent p;
divides_opp (- p) a;
divides_mod a p) | false |
Vale.Wrapper.X64.Sha.fsti | Vale.Wrapper.X64.Sha.uint32_i | val uint32_i : Type0 | let uint32_i = IB.ibuffer uint32 | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.Sha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 32,
"end_line": 17,
"start_col": 0,
"start_line": 17
} | module Vale.Wrapper.X64.Sha
open Vale.X64.CPU_Features_s
open FStar.HyperStack.ST
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module BF = Vale.Arch.BufferFriend
open FStar.Mul
open Vale.SHA.SHA_helpers
open Lib.IntTypes
unfold
let uint32_p = B.buffer uint32 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Arch.BufferFriend.fsti.checked",
"Spec.SHA2.Constants.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Wrapper.X64.Sha.fsti"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.BufferFriend",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | Type0 | Prims.Tot | [
"total"
]
| []
| [
"LowStar.ImmutableBuffer.ibuffer",
"Lib.IntTypes.uint32"
]
| []
| false | false | false | true | true | let uint32_i =
| IB.ibuffer uint32 | false |
|
FStar.DM4F.IntStoreFixed.fst | FStar.DM4F.IntStoreFixed.op_Colon_equals | val op_Colon_equals : i: FStar.DM4F.Heap.IntStoreFixed.id -> x: Prims.int -> FStar.DM4F.IntStoreFixed.INT_STORE Prims.unit | let op_Colon_equals = write | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixed.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"end_line": 83,
"start_col": 0,
"start_line": 83
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixed
open FStar.DM4F.Heap.IntStoreFixed
(* TODO : Try to use [either a exn] instead of [option] *)
type int_store (a:Type) = heap -> M (a * heap)
let return_is (a:Type) (x:a) : int_store a = fun store -> x, store
let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b =
fun store ->
let (z, store') = x store in
f z store'
let iget () : int_store heap = fun store -> store, store
let iput s : int_store unit = fun _ -> (), s
total reifiable reflectable new_effect {
INT_STORE : a:Type -> Effect
with repr = int_store
; bind = bind_is
; return = return_is
; get = iget
; put = iput
}
let get = INT_STORE?.get
let put = INT_STORE?.put
effect IntStore (a:Type) (pre:INT_STORE?.pre) (post: heap -> a -> heap -> GTot Type0) =
INT_STORE a (fun l0 p -> pre l0 /\ (forall x l1. pre l0 /\ post l0 x l1 ==> p (x, l1)))
effect IS (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a). p (x, l0))
effect ISNull (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a * heap). p x)
(* TODO : having a in Type *and* induces a Failure("Universe variable not found") *)
(* whenever we try to normalize-reify it (see below in xxx for instance) *)
let wp = INT_STORE?.wp
let pre = INT_STORE?.pre
let post = INT_STORE?.post
let repr = INT_STORE?.repr
let read (i:id)
: INT_STORE int (fun s0 p -> p (index s0 i, s0))
=
let store = IS?.get () in
index store i
let write (i:id) (x:int)
: INT_STORE unit (fun s0 p -> p ((), upd s0 i x))
=
let store = IS?.get () in
IS?.put (upd store i x)
(* let read_does_not_write_lemma (h:heap) (x:id) *)
(* : Lemma (requires True) *)
(* (ensures (snd (reify (read x) h) == h)) *)
(* [SMTPat (snd (reify (read x) h))] *)
(* = () *)
unfold
let (!) = read | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixedReader.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixed.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | i: FStar.DM4F.Heap.IntStoreFixed.id -> x: Prims.int -> FStar.DM4F.IntStoreFixed.INT_STORE Prims.unit | FStar.DM4F.IntStoreFixed.INT_STORE | []
| []
| [
"FStar.DM4F.IntStoreFixed.write"
]
| []
| false | true | false | false | false | let op_Colon_equals =
| write | false |
|
Vale.Wrapper.X64.Sha.fsti | Vale.Wrapper.X64.Sha.uint8_p | val uint8_p : Type0 | let uint8_p = B.buffer uint8 | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.Sha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 19,
"start_col": 0,
"start_line": 19
} | module Vale.Wrapper.X64.Sha
open Vale.X64.CPU_Features_s
open FStar.HyperStack.ST
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module BF = Vale.Arch.BufferFriend
open FStar.Mul
open Vale.SHA.SHA_helpers
open Lib.IntTypes
unfold
let uint32_p = B.buffer uint32
unfold
let uint32_i = IB.ibuffer uint32 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Arch.BufferFriend.fsti.checked",
"Spec.SHA2.Constants.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Wrapper.X64.Sha.fsti"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.BufferFriend",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | Type0 | Prims.Tot | [
"total"
]
| []
| [
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint8"
]
| []
| false | false | false | true | true | let uint8_p =
| B.buffer uint8 | false |
|
FStar.DM4F.IntStoreFixed.fst | FStar.DM4F.IntStoreFixed.lift_int_store_reader_int_store_wp | val lift_int_store_reader_int_store_wp (a: Type) (wp: INT_STORE_READER?.wp a) : INT_STORE?.wp a | val lift_int_store_reader_int_store_wp (a: Type) (wp: INT_STORE_READER?.wp a) : INT_STORE?.wp a | let lift_int_store_reader_int_store_wp (a:Type) (wp:INT_STORE_READER?.wp a) : INT_STORE?.wp a =
fun (h0:heap) (p:INT_STORE?.post a) -> wp h0 (fun r -> p (r, h0)) | {
"file_name": "examples/dm4free/FStar.DM4F.IntStoreFixed.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 67,
"end_line": 110,
"start_col": 0,
"start_line": 109
} | (*
Copyright 2008-2018 Microsoft Research
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*)
module FStar.DM4F.IntStoreFixed
open FStar.DM4F.Heap.IntStoreFixed
(* TODO : Try to use [either a exn] instead of [option] *)
type int_store (a:Type) = heap -> M (a * heap)
let return_is (a:Type) (x:a) : int_store a = fun store -> x, store
let bind_is (a b : Type) (x:int_store a) (f: a -> int_store b) : int_store b =
fun store ->
let (z, store') = x store in
f z store'
let iget () : int_store heap = fun store -> store, store
let iput s : int_store unit = fun _ -> (), s
total reifiable reflectable new_effect {
INT_STORE : a:Type -> Effect
with repr = int_store
; bind = bind_is
; return = return_is
; get = iget
; put = iput
}
let get = INT_STORE?.get
let put = INT_STORE?.put
effect IntStore (a:Type) (pre:INT_STORE?.pre) (post: heap -> a -> heap -> GTot Type0) =
INT_STORE a (fun l0 p -> pre l0 /\ (forall x l1. pre l0 /\ post l0 x l1 ==> p (x, l1)))
effect IS (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a). p (x, l0))
effect ISNull (a:Type) =
INT_STORE a (fun (l0:heap) (p:((a * heap) -> Type0)) -> forall (x:a * heap). p x)
(* TODO : having a in Type *and* induces a Failure("Universe variable not found") *)
(* whenever we try to normalize-reify it (see below in xxx for instance) *)
let wp = INT_STORE?.wp
let pre = INT_STORE?.pre
let post = INT_STORE?.post
let repr = INT_STORE?.repr
let read (i:id)
: INT_STORE int (fun s0 p -> p (index s0 i, s0))
=
let store = IS?.get () in
index store i
let write (i:id) (x:int)
: INT_STORE unit (fun s0 p -> p ((), upd s0 i x))
=
let store = IS?.get () in
IS?.put (upd store i x)
(* let read_does_not_write_lemma (h:heap) (x:id) *)
(* : Lemma (requires True) *)
(* (ensures (snd (reify (read x) h) == h)) *)
(* [SMTPat (snd (reify (read x) h))] *)
(* = () *)
unfold
let (!) = read
unfold
let op_Colon_equals = write
assume
val refine_st (#a:Type)
(#b:Type)
(#pre : a -> Tot INT_STORE?.pre)
(#post : a -> Tot (heap -> b -> heap -> Tot Type0))
($f :(x:a -> IntStore b (pre x) (post x)))
(x:a)
: IntStore b (pre x) (fun h0 z h1 -> pre x h0 /\
reify (f x) h0 == (z, h1) /\
post x h0 z h1)
// = let g (h0:heap)
// : Pure (b * heap)
// (pre x h0)
// (fun (z,h1) -> pre x h0 /\
// reify (f x) h0 == (z, h1) /\
// post x h0 z h1)
// = reify (f x) h0
// in
// IntStore?.reflect g
open FStar.DM4F.IntStoreFixedReader | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.DM4F.IntStoreFixedReader.fst.checked",
"FStar.DM4F.Heap.IntStoreFixed.fsti.checked"
],
"interface_file": false,
"source_file": "FStar.DM4F.IntStoreFixed.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.DM4F.IntStoreFixedReader",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F.Heap.IntStoreFixed",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.DM4F",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false | a: Type -> wp: FStar.DM4F.IntStoreFixedReader._dm4f_INT_STORE_READER_wp a
-> FStar.DM4F.IntStoreFixed._dm4f_INT_STORE_wp a | Prims.Tot | [
"total"
]
| []
| [
"FStar.DM4F.IntStoreFixedReader._dm4f_INT_STORE_READER_wp",
"FStar.DM4F.Heap.IntStoreFixed.heap",
"FStar.DM4F.IntStoreFixed._dm4f_INT_STORE_post",
"FStar.Pervasives.Native.Mktuple2",
"FStar.DM4F.IntStoreFixed._dm4f_INT_STORE_wp"
]
| []
| false | false | false | true | false | let lift_int_store_reader_int_store_wp (a: Type) (wp: INT_STORE_READER?.wp a) : INT_STORE?.wp a =
| fun (h0: heap) (p: INT_STORE?.post a) -> wp h0 (fun r -> p (r, h0)) | false |
Vale.Def.Words.Four_s.fsti | Vale.Def.Words.Four_s.four_select | val four_select (#a: Type) (x: four a) (selector: nat2) : a | val four_select (#a: Type) (x: four a) (selector: nat2) : a | let four_select (#a:Type) (x:four a) (selector:nat2) : a =
match selector with
| 0 -> x.lo0
| 1 -> x.lo1
| 2 -> x.hi2
| 3 -> x.hi3 | {
"file_name": "vale/specs/defs/Vale.Def.Words.Four_s.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 52,
"start_col": 0,
"start_line": 47
} | module Vale.Def.Words.Four_s
open Vale.Def.Words_s
open FStar.Mul
unfold let four_map (#a #b:Type) (f:a -> b) (x:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
Mkfour (f x0) (f x1) (f x2) (f x3)
unfold let four_map2 (#a #b:Type) (f:a -> a -> b) (x y:four a) : four b =
let Mkfour x0 x1 x2 x3 = x in
let Mkfour y0 y1 y2 y3 = y in
Mkfour (f x0 y0) (f x1 y1) (f x2 y2) (f x3 y3)
let two_two_to_four (#a:Type) (x:two (two a)) : four a =
let (Mktwo (Mktwo x0 x1) (Mktwo x2 x3)) = x in
Mkfour x0 x1 x2 x3
let four_to_two_two (#a:Type) (x:four a) : two (two a) =
let Mkfour x0 x1 x2 x3 = x in
Mktwo (Mktwo x0 x1) (Mktwo x2 x3)
unfold
let nat_to_four_unfold (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
Mkfour (n % n1) ((n / n1) % n1) ((n / n2) % n1) ((n / n3) % n1)
[@"opaque_to_smt"]
let nat_to_four (size:nat) (n:natN (pow2 (4 * size))) : four (natN (pow2 size)) =
nat_to_four_unfold size n
unfold
let four_to_nat_unfold (size:nat) (x:four (natN (pow2 size))) : natN (pow2 (4 * size)) =
let n1 = pow2_norm size in
let n2 = pow2_norm (2 * size) in
let n3 = pow2_norm (3 * size) in
let n4 = pow2_norm (4 * size) in
let Mkfour x0 x1 x2 x3 = x in
int_to_natN n4 (x0 + x1 * n1 + x2 * n2 + x3 * n3)
[@"opaque_to_smt"]
let four_to_nat (size:nat) (x:four (natN (pow2 size))) : natN (pow2 (4 * size)) =
four_to_nat_unfold size x | {
"checked_file": "/",
"dependencies": [
"Vale.Def.Words_s.fsti.checked",
"prims.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Def.Words.Four_s.fsti"
} | [
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | x: Vale.Def.Words_s.four a -> selector: Vale.Def.Words_s.nat2 -> a | Prims.Tot | [
"total"
]
| []
| [
"Vale.Def.Words_s.four",
"Vale.Def.Words_s.nat2",
"Vale.Def.Words_s.__proj__Mkfour__item__lo0",
"Vale.Def.Words_s.__proj__Mkfour__item__lo1",
"Vale.Def.Words_s.__proj__Mkfour__item__hi2",
"Vale.Def.Words_s.__proj__Mkfour__item__hi3"
]
| []
| false | false | false | true | false | let four_select (#a: Type) (x: four a) (selector: nat2) : a =
| match selector with
| 0 -> x.lo0
| 1 -> x.lo1
| 2 -> x.hi2
| 3 -> x.hi3 | false |
Vale.Wrapper.X64.Sha.fsti | Vale.Wrapper.X64.Sha.uint32_p | val uint32_p : Type0 | let uint32_p = B.buffer uint32 | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.Sha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 30,
"end_line": 15,
"start_col": 0,
"start_line": 15
} | module Vale.Wrapper.X64.Sha
open Vale.X64.CPU_Features_s
open FStar.HyperStack.ST
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module BF = Vale.Arch.BufferFriend
open FStar.Mul
open Vale.SHA.SHA_helpers
open Lib.IntTypes | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Arch.BufferFriend.fsti.checked",
"Spec.SHA2.Constants.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Wrapper.X64.Sha.fsti"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.BufferFriend",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | Type0 | Prims.Tot | [
"total"
]
| []
| [
"LowStar.Buffer.buffer",
"Lib.IntTypes.uint32"
]
| []
| false | false | false | true | true | let uint32_p =
| B.buffer uint32 | false |
|
FStar.Math.Euclid.fst | FStar.Math.Euclid.egcd | val egcd (a b u1 u2 u3 v1 v2 v3:int) : Pure (int & int & int)
(requires v3 >= 0 /\
u1 * a + u2 * b = u3 /\
v1 * a + v2 * b = v3 /\
(forall d. is_gcd u3 v3 d ==> is_gcd a b d))
(ensures (fun (u, v, d) -> u * a + v * b = d /\ is_gcd a b d))
(decreases v3) | val egcd (a b u1 u2 u3 v1 v2 v3:int) : Pure (int & int & int)
(requires v3 >= 0 /\
u1 * a + u2 * b = u3 /\
v1 * a + v2 * b = v3 /\
(forall d. is_gcd u3 v3 d ==> is_gcd a b d))
(ensures (fun (u, v, d) -> u * a + v * b = d /\ is_gcd a b d))
(decreases v3) | let rec egcd a b u1 u2 u3 v1 v2 v3 =
if v3 = 0 then
begin
divides_0 u3;
(u1, u2, u3)
end
else
begin
let q = u3 / v3 in
euclidean_division_definition u3 v3;
assert (u3 - q * v3 = (q * v3 + u3 % v3) - q * v3);
assert (q * v3 - q * v3 = 0);
swap_add_plus_minus (q * v3) (u3 % v3) (q * v3);
calc (==) {
(u1 - q * v1) * a + (u2 - q * v2) * b;
== { _ by (FStar.Tactics.Canon.canon()) }
(u1 * a + u2 * b) - q * (v1 * a + v2 * b);
== { }
u3 - q * v3;
== { lemma_div_mod u3 v3 }
u3 % v3;
};
let u1, v1 = v1, u1 - q * v1 in
let u2, v2 = v2, u2 - q * v2 in
let u3' = u3 in
let v3' = v3 in
let u3, v3 = v3, u3 - q * v3 in
(* proving the implication in the precondition *)
introduce forall d. is_gcd v3' (u3' - q * v3') d ==> is_gcd u3' v3' d with
introduce _ ==> _ with _.
is_gcd_for_euclid u3' v3' q d;
let r = egcd a b u1 u2 u3 v1 v2 v3 in
r
end | {
"file_name": "ulib/FStar.Math.Euclid.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 7,
"end_line": 182,
"start_col": 0,
"start_line": 149
} | module FStar.Math.Euclid
open FStar.Mul
open FStar.Math.Lemmas
///
/// Auxiliary lemmas
///
val eq_mult_left (a b:int) : Lemma (requires a = b * a) (ensures a = 0 \/ b = 1)
let eq_mult_left a b = ()
val eq_mult_one (a b:int) : Lemma
(requires a * b = 1)
(ensures (a = 1 /\ b = 1) \/ (a = -1 /\ b = -1))
let eq_mult_one a b = ()
val opp_idempotent (a:int) : Lemma (-(-a) == a)
let opp_idempotent a = ()
val add_sub_l (a b:int) : Lemma (a - b + b = a)
let add_sub_l a b = ()
val add_sub_r (a b:int) : Lemma (a + b - b = a)
let add_sub_r a b = ()
///
/// Divides relation
///
let divides_reflexive a =
Classical.exists_intro (fun q -> a = q * a) 1
let divides_transitive a b c =
eliminate exists q1. b == q1 * a
returns a `divides` c
with _pf.
eliminate exists q2. c == q2 * b
returns _
with _pf2.
introduce exists q. c == q * a
with (q1 * q2)
and ()
let divide_antisym a b =
if a <> 0 then
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q1. b = q1 * a))
(fun q1 ->
Classical.exists_elim (a = b \/ a = -b) (Squash.get_proof (exists q2. a = q2 * b))
(fun q2 ->
assert (b = q1 * a);
assert (a = q2 * b);
assert (b = q1 * (q2 * b));
paren_mul_right q1 q2 b;
eq_mult_left b (q1 * q2);
eq_mult_one q1 q2))
let divides_0 a =
Classical.exists_intro (fun q -> 0 = q * a) 0
let divides_1 a = ()
let divides_minus a b =
Classical.exists_elim (a `divides` (-b))
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> -b = q' * a) (-q))
let divides_opp a b =
Classical.exists_elim ((-a) `divides` b)
(Squash.get_proof (a `divides` b))
(fun q -> Classical.exists_intro (fun q' -> b = q' * (-a)) (-q))
let divides_plus a b d =
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q1. a = q1 * d))
(fun q1 ->
Classical.exists_elim (d `divides` (a + b)) (Squash.get_proof (exists q2. b = q2 * d))
(fun q2 ->
assert (a + b = q1 * d + q2 * d);
distributivity_add_left q1 q2 d;
Classical.exists_intro (fun q -> a + b = q * d) (q1 + q2)))
let divides_sub a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_plus a (-b) d
let divides_mult_right a b d =
Classical.exists_elim (d `divides` (a * b)) (Squash.get_proof (d `divides` b))
(fun q ->
paren_mul_right a q d;
Classical.exists_intro (fun r -> a * b = r * d) (a * q))
///
/// GCD
///
let mod_divides a b =
Classical.exists_intro (fun q -> a = q * b) (a / b)
let divides_mod a b =
Classical.exists_elim (a % b = 0) (Squash.get_proof (b `divides` a))
(fun q -> cancel_mul_div q b)
let is_gcd_unique a b c d =
divide_antisym c d
let is_gcd_reflexive a = ()
let is_gcd_symmetric a b d = ()
let is_gcd_0 a = ()
let is_gcd_1 a = ()
let is_gcd_minus a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
opp_idempotent b
let is_gcd_opp a b d =
Classical.forall_intro_2 (Classical.move_requires_2 divides_minus);
divides_opp d a;
divides_opp d b
let is_gcd_plus a b q d =
add_sub_r b (q * a);
Classical.forall_intro_3 (Classical.move_requires_3 divides_plus);
Classical.forall_intro_3 (Classical.move_requires_3 divides_mult_right);
Classical.forall_intro_3 (Classical.move_requires_3 divides_sub)
///
/// Extended Euclidean algorithm
///
val is_gcd_for_euclid (a b q d:int) : Lemma
(requires is_gcd b (a - q * b) d)
(ensures is_gcd a b d)
let is_gcd_for_euclid a b q d =
add_sub_l a (q * b);
is_gcd_plus b (a - q * b) q d
val egcd (a b u1 u2 u3 v1 v2 v3:int) : Pure (int & int & int)
(requires v3 >= 0 /\
u1 * a + u2 * b = u3 /\
v1 * a + v2 * b = v3 /\
(forall d. is_gcd u3 v3 d ==> is_gcd a b d))
(ensures (fun (u, v, d) -> u * a + v * b = d /\ is_gcd a b d))
(decreases v3) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Tactics.Canon.fst.checked",
"FStar.Squash.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.Classical.Sugar.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": true,
"source_file": "FStar.Math.Euclid.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Math.Lemmas",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 2,
"initial_ifuel": 1,
"max_fuel": 8,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_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"
} | false |
a: Prims.int ->
b: Prims.int ->
u1: Prims.int ->
u2: Prims.int ->
u3: Prims.int ->
v1: Prims.int ->
v2: Prims.int ->
v3: Prims.int
-> Prims.Pure ((Prims.int * Prims.int) * Prims.int) | Prims.Pure | [
""
]
| []
| [
"Prims.int",
"Prims.op_Equality",
"FStar.Pervasives.Native.Mktuple3",
"Prims.unit",
"FStar.Math.Euclid.divides_0",
"Prims.bool",
"Prims.precedes",
"FStar.Pervasives.Native.tuple3",
"FStar.Math.Euclid.egcd",
"FStar.Classical.Sugar.forall_intro",
"Prims.l_imp",
"FStar.Math.Euclid.is_gcd",
"Prims.op_Subtraction",
"FStar.Mul.op_Star",
"FStar.Classical.Sugar.implies_intro",
"Prims.squash",
"FStar.Math.Euclid.is_gcd_for_euclid",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Calc.calc_finish",
"Prims.eq2",
"Prims.op_Addition",
"Prims.op_Modulus",
"Prims.Cons",
"FStar.Preorder.relation",
"Prims.Nil",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Math.Lemmas.lemma_div_mod",
"FStar.Math.Lemmas.swap_add_plus_minus",
"Prims._assert",
"Prims.b2t",
"FStar.Math.Lemmas.euclidean_division_definition",
"Prims.op_Division"
]
| [
"recursion"
]
| false | false | false | false | false | let rec egcd a b u1 u2 u3 v1 v2 v3 =
| if v3 = 0
then
(divides_0 u3;
(u1, u2, u3))
else
let q = u3 / v3 in
euclidean_division_definition u3 v3;
assert (u3 - q * v3 = (q * v3 + u3 % v3) - q * v3);
assert (q * v3 - q * v3 = 0);
swap_add_plus_minus (q * v3) (u3 % v3) (q * v3);
calc ( == ) {
(u1 - q * v1) * a + (u2 - q * v2) * b;
( == ) { FStar.Tactics.Effect.synth_by_tactic (fun _ -> (FStar.Tactics.Canon.canon ())) }
(u1 * a + u2 * b) - q * (v1 * a + v2 * b);
( == ) { () }
u3 - q * v3;
( == ) { lemma_div_mod u3 v3 }
u3 % v3;
};
let u1, v1 = v1, u1 - q * v1 in
let u2, v2 = v2, u2 - q * v2 in
let u3' = u3 in
let v3' = v3 in
let u3, v3 = v3, u3 - q * v3 in
introduce forall d . is_gcd v3' (u3' - q * v3') d ==> is_gcd u3' v3' d
with introduce _ ==> _
with _. is_gcd_for_euclid u3' v3' q d;
let r = egcd a b u1 u2 u3 v1 v2 v3 in
r | false |
Vale.Wrapper.X64.Sha.fsti | Vale.Wrapper.X64.Sha.uint64 | val uint64 : Type0 | let uint64 = uint_t U64 PUB | {
"file_name": "vale/code/arch/x64/interop/Vale.Wrapper.X64.Sha.fsti",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 27,
"end_line": 21,
"start_col": 0,
"start_line": 21
} | module Vale.Wrapper.X64.Sha
open Vale.X64.CPU_Features_s
open FStar.HyperStack.ST
module B = LowStar.Buffer
module IB = LowStar.ImmutableBuffer
module BV = LowStar.BufferView
module HS = FStar.HyperStack
module BF = Vale.Arch.BufferFriend
open FStar.Mul
open Vale.SHA.SHA_helpers
open Lib.IntTypes
unfold
let uint32_p = B.buffer uint32
unfold
let uint32_i = IB.ibuffer uint32
unfold
let uint8_p = B.buffer uint8 | {
"checked_file": "/",
"dependencies": [
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.SHA.SHA_helpers.fsti.checked",
"Vale.Arch.BufferFriend.fsti.checked",
"Spec.SHA2.Constants.fst.checked",
"prims.fst.checked",
"LowStar.ImmutableBuffer.fst.checked",
"LowStar.BufferView.fsti.checked",
"LowStar.Buffer.fst.checked",
"Lib.IntTypes.fsti.checked",
"FStar.UInt64.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Vale.Wrapper.X64.Sha.fsti"
} | [
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.SHA.SHA_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Arch.BufferFriend",
"short_module": "BF"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"abbrev": true,
"full_module": "LowStar.BufferView",
"short_module": "BV"
},
{
"abbrev": true,
"full_module": "LowStar.ImmutableBuffer",
"short_module": "IB"
},
{
"abbrev": true,
"full_module": "LowStar.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Wrapper.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
]
| {
"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"
} | false | Type0 | Prims.Tot | [
"total"
]
| []
| [
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U64",
"Lib.IntTypes.PUB"
]
| []
| false | false | false | true | true | let uint64 =
| uint_t U64 PUB | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.