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
sequencelengths 0
2
| mutual_with
sequencelengths 0
11
| ideal_premises
sequencelengths 0
236
| proof_features
sequencelengths 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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AlgHeap.fst | AlgHeap.equiv | val equiv : w1: AlgHeap.st_wp a -> w2: AlgHeap.st_wp a -> Prims.logical | let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1 | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 69,
"end_line": 262,
"start_col": 0,
"start_line": 262
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | w1: AlgHeap.st_wp a -> w2: AlgHeap.st_wp a -> Prims.logical | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.st_wp",
"Prims.l_and",
"AlgHeap.stronger",
"Prims.logical"
] | [] | false | false | false | true | true | let equiv #a (w1: st_wp a) (w2: st_wp a) =
| w1 `stronger` w2 /\ w2 `stronger` w1 | false |
|
AlgHeap.fst | AlgHeap._get | val _get:tree state [Read] | val _get:tree state [Read] | let _get : tree state [Read] = Op Read () Return | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 48,
"end_line": 174,
"start_col": 0,
"start_line": 174
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | AlgHeap.tree AlgHeap.state [AlgHeap.Read] | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.Op",
"AlgHeap.state",
"AlgHeap.Read",
"AlgHeap.Return"
] | [] | false | false | false | true | false | let _get:tree state [Read] =
| Op Read () Return | false |
AlgHeap.fst | AlgHeap.fold_with | val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b | val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b | let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k' | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 14,
"end_line": 129,
"start_col": 0,
"start_line": 122
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 |
f: AlgHeap.tree a labs ->
v: (_: a -> b) ->
h:
(
o: AlgHeap.op{FStar.List.Tot.Base.mem o labs} ->
_: AlgHeap.op_inp o ->
_: (_: AlgHeap.op_out o -> b)
-> b)
-> b | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.ops",
"AlgHeap.tree",
"AlgHeap.op",
"Prims.b2t",
"FStar.List.Tot.Base.mem",
"AlgHeap.op_inp",
"AlgHeap.op_out",
"AlgHeap.tree0",
"AlgHeap.fold_with"
] | [
"recursion"
] | false | false | false | false | false | let rec fold_with #a #b #labs f v h =
| match f with
| Return x -> v x
| Op act i k ->
let k' (o: op_out act) : b = fold_with #_ #_ #labs (k o) v h in
h act i k' | false |
AlgHeap.fst | AlgHeap.get | val get: Prims.unit -> Alg state [Read] | val get: Prims.unit -> Alg state [Read] | let get () : Alg state [Read] =
Alg?.reflect _get | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 19,
"end_line": 187,
"start_col": 0,
"start_line": 186
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 -> AlgHeap.Alg AlgHeap.state | AlgHeap.Alg | [] | [] | [
"Prims.unit",
"AlgHeap._get",
"AlgHeap.state",
"Prims.Cons",
"AlgHeap.op",
"AlgHeap.Read",
"Prims.Nil"
] | [] | false | true | false | false | false | let get () : Alg state [Read] =
| Alg?.reflect _get | false |
AlgHeap.fst | AlgHeap.put | val put (s: state) : Alg unit [Write] | val put (s: state) : Alg unit [Write] | let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 23,
"end_line": 202,
"start_col": 0,
"start_line": 201
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | s: AlgHeap.state -> AlgHeap.Alg Prims.unit | AlgHeap.Alg | [] | [] | [
"AlgHeap.state",
"AlgHeap._put",
"Prims.unit",
"Prims.Cons",
"AlgHeap.op",
"AlgHeap.Write",
"Prims.Nil"
] | [] | false | true | false | false | false | let put (s: state) : Alg unit [Write] =
| Alg?.reflect (_put s) | false |
AlgHeap.fst | AlgHeap.repr | val repr : a: Type -> w: AlgHeap.st_wp a -> Type | let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c} | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 43,
"end_line": 341,
"start_col": 0,
"start_line": 340
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 -> w: AlgHeap.st_wp a -> Type | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.st_wp",
"AlgHeap.rwtree",
"AlgHeap.stronger",
"AlgHeap.interp_as_wp"
] | [] | false | false | false | true | true | let repr (a: Type) (w: st_wp a) =
| c: (rwtree a){w `stronger` (interp_as_wp c)} | false |
|
AlgHeap.fst | AlgHeap.tbind | val tbind: #a: _ -> #b: _ -> rwtree a -> (a -> rwtree b) -> rwtree b | val tbind: #a: _ -> #b: _ -> rwtree a -> (a -> rwtree b) -> rwtree b | let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 93,
"end_line": 212,
"start_col": 0,
"start_line": 212
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | c: AlgHeap.rwtree a -> f: (_: a -> AlgHeap.rwtree b) -> AlgHeap.rwtree b | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.rwtree",
"AlgHeap.bind",
"Prims.Cons",
"AlgHeap.op",
"AlgHeap.Read",
"AlgHeap.Write",
"Prims.Nil"
] | [] | false | false | false | true | false | let tbind: #a: _ -> #b: _ -> rwtree a -> (a -> rwtree b) -> rwtree b =
| fun c f -> bind _ _ c f | false |
AlgHeap.fst | AlgHeap.subcomp | val subcomp (a: Type) (labs1 labs2: ops) (f: tree a labs1)
: Pure (tree a labs2) (requires (sublist labs1 labs2)) (ensures (fun _ -> True)) | val subcomp (a: Type) (labs1 labs2: ops) (f: tree a labs1)
: Pure (tree a labs2) (requires (sublist labs1 labs2)) (ensures (fun _ -> True)) | let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 163,
"start_col": 0,
"start_line": 157
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 -> labs1: AlgHeap.ops -> labs2: AlgHeap.ops -> f: AlgHeap.tree a labs1
-> Prims.Pure (AlgHeap.tree a labs2) | Prims.Pure | [] | [] | [
"AlgHeap.ops",
"AlgHeap.tree",
"AlgHeap.sublist",
"Prims.l_True"
] | [] | false | false | false | false | false | let subcomp (a: Type) (labs1 labs2: ops) (f: tree a labs1)
: Pure (tree a labs2) (requires (sublist labs1 labs2)) (ensures (fun _ -> True)) =
| f | false |
AlgHeap.fst | AlgHeap._put | val _put (s: state) : tree unit [Write] | val _put (s: state) : tree unit [Write] | let _put (s:state) : tree unit [Write] = Op Write s Return | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 176,
"start_col": 0,
"start_line": 176
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | s: AlgHeap.state -> AlgHeap.tree Prims.unit [AlgHeap.Write] | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.state",
"AlgHeap.Op",
"Prims.unit",
"AlgHeap.Write",
"AlgHeap.Return",
"AlgHeap.tree",
"Prims.Cons",
"AlgHeap.op",
"Prims.Nil"
] | [] | false | false | false | true | false | let _put (s: state) : tree unit [Write] =
| Op Write s Return | false |
Hacl.Impl.RSAPSS.fst | Hacl.Impl.RSAPSS.rsapss_sign_compute_sgnt | val rsapss_sign_compute_sgnt:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_sign_compute_sgnt_st t ke modBits | val rsapss_sign_compute_sgnt:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_sign_compute_sgnt_st t ke modBits | let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt =
push_frame ();
let h_init = ST.get () in
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
let m' = create nLen (uint #t 0) in
let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_to_bytes_be k s sgnt;
pop_frame ();
eq_b | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 181,
"start_col": 0,
"start_line": 164
} | module Hacl.Impl.RSAPSS
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module Hash = Spec.Agile.Hash
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module SD = Hacl.Spec.Bignum.Definitions
module SM = Hacl.Spec.Bignum.Montgomery
module SE = Hacl.Spec.Bignum.Exponentiation
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module S = Spec.RSAPSS
module LS = Hacl.Spec.RSAPSS
module LSeq = Lib.Sequence
module RP = Hacl.Impl.RSAPSS.Padding
module RM = Hacl.Impl.RSAPSS.MGF
module RK = Hacl.Impl.RSAPSS.Keys
#reset-options "--z3rlimit 150 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
inline_for_extraction noextract
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> m':lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h skey /\ live h m /\ live h s /\ live h m' /\
disjoint s m /\ disjoint s skey /\ disjoint m skey /\
disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\
(r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let eLen = blocks eBits (size bits) in
let dLen = blocks dBits (size bits) in
let n = sub skey 0ul nLen in
let r2 = sub skey nLen nLen in
let e = sub skey (nLen +! nLen) eLen in
let d = sub skey (nLen +! nLen +! eLen) dLen in
Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits);
let h0 = ST.get () in
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n);
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s;
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m';
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 s)
(SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h0 m) (v dBits) (as_seq h0 d));
SD.bn_eval_inj (v nLen) (as_seq h1 m')
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
let eq_m = BN.bn_eq_mask nLen m m' in
mapT nLen s (logand eq_m) s;
BB.unsafe_bool_of_limb eq_m
inline_for_extraction noextract
let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t len ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h m /\
disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\
as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_msg_to_bn:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_msg_to_bn_st t a modBits
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
RP.pss_encode a saltLen salt msgLen msg emBits em;
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits = v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let h' = ST.get () in
update_sub_f h' m 0ul mLen
(fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em))
(fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen));
pop_frame ()
inline_for_extraction noextract
let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h skey /\ live h m /\
disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_compute_sgnt:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_sign_compute_sgnt_st t ke modBits | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.RSAPSS.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.RSAPSS.Padding.fst.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Impl.RSAPSS.Keys.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Keys",
"short_module": "RK"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": "RM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Padding",
"short_module": "RP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.RSAPSS",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | ke: Hacl.Bignum.Exponentiation.exp t -> modBits: Hacl.Impl.RSAPSS.modBits_t t
-> Hacl.Impl.RSAPSS.rsapss_sign_compute_sgnt_st t ke modBits | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Exponentiation.exp",
"Hacl.Impl.RSAPSS.modBits_t",
"Lib.IntTypes.size_t",
"Hacl.Spec.RSAPSS.skey_len_pre",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Hacl.Bignum.Definitions.blocks",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Bignum.bn_to_bytes_be",
"Prims._assert",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.max_size_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Prims.l_and",
"Prims.op_GreaterThan",
"Lib.IntTypes.range",
"Hacl.Spec.Bignum.Definitions.blocks",
"Hacl.Spec.RSAPSS.blocks_numb_lemma",
"Hacl.Spec.RSAPSS.blocks_bits_lemma",
"Hacl.Impl.RSAPSS.rsapss_sign_bn",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int_t",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.IntTypes.mk_int",
"Prims.pos",
"Lib.IntTypes.numbytes",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt =
| push_frame ();
let h_init = ST.get () in
[@@ inline_let ]let bits:size_pos = bits t in
[@@ inline_let ]let numb:size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
let m' = create nLen (uint #t 0) in
let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_to_bytes_be k s sgnt;
pop_frame ();
eq_b | false |
AlgHeap.fst | AlgHeap.raise | val raise (#a: _) (e: exn) : Alg a [Raise] | val raise (#a: _) (e: exn) : Alg a [Raise] | let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with)) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 205,
"start_col": 0,
"start_line": 204
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | e: Prims.exn -> AlgHeap.Alg a | AlgHeap.Alg | [] | [] | [
"Prims.exn",
"AlgHeap.Op",
"AlgHeap.Raise",
"AlgHeap.op_out",
"AlgHeap.tree0",
"Prims.Cons",
"AlgHeap.op",
"Prims.Nil"
] | [] | false | true | false | false | false | let raise #a (e: exn) : Alg a [Raise] =
| Alg?.reflect (Op Raise e (function )) | false |
SolveThen.fst | SolveThen.f3 | val f3:int | val f3:int | let f3 : int = _ by (fib 3) | {
"file_name": "examples/tactics/SolveThen.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 27,
"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 SolveThen
open FStar.Tactics.V2
let rec fib n : Tac unit = if n < 2 then exact (`1) else (apply (`(+)); fib (n - 1); fib (n - 2)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "SolveThen.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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.int | Prims.Tot | [
"total"
] | [] | [
"Prims.op_Addition"
] | [] | false | false | false | true | false | let f3:int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ -> (fib 3)) | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_wpProof_Gcm_blocks_decrypt_stdcall | val va_wpProof_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> auth_b:buffer128 ->
auth_bytes:nat64 -> auth_num:nat64 -> keys_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
hkeys_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
len128x6_num:nat64 -> in128_b:buffer128 -> out128_b:buffer128 -> len128_num:nat64 ->
inout_b:buffer128 -> cipher_num:nat64 -> scratch_b:buffer128 -> tag_b:buffer128 -> key:(seq
nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes
auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b
len128_num inout_b cipher_num scratch_b tag_b key va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_decrypt_stdcall win alg)
([va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64
rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | val va_wpProof_Gcm_blocks_decrypt_stdcall : win:bool -> alg:algorithm -> auth_b:buffer128 ->
auth_bytes:nat64 -> auth_num:nat64 -> keys_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
hkeys_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
len128x6_num:nat64 -> in128_b:buffer128 -> out128_b:buffer128 -> len128_num:nat64 ->
inout_b:buffer128 -> cipher_num:nat64 -> scratch_b:buffer128 -> tag_b:buffer128 -> key:(seq
nat32) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes
auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b
len128_num inout_b cipher_num scratch_b tag_b key va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_decrypt_stdcall win alg)
([va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64
rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM,
va_f0, va_g)))) | let va_wpProof_Gcm_blocks_decrypt_stdcall win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b
abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num
scratch_b tag_b key va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks_decrypt_stdcall (va_code_Gcm_blocks_decrypt_stdcall win
alg) va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b
out128x6_b len128x6_num in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_stackTaint va_sM (va_update_stack va_sM (va_update_flags
va_sM (va_update_mem_layout va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet 5 va_sM
(va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1 va_sM
(va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM
(va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM
(va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM
(va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM
(va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax;
va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 22,
"end_line": 2352,
"start_col": 0,
"start_line": 2321
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE:quad32 ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks : alg:algorithm -> offset:int -> auth_b:buffer128 -> abytes_b:buffer128
-> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 -> out128_b:buffer128 ->
inout_b:buffer128 -> iv_b:buffer128 -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks alg offset) ([va_Mod_flags;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks (va_code_Gcm_blocks alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gcm_blocks alg
offset)) =
(va_QProc (va_code_Gcm_blocks alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b) (va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b))
#pop-options
//--
//-- Gcm_blocks_wrapped
#push-options "--z3rlimit 60"
val va_code_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_wrapped alg offset =
(va_Block (va_CCons (va_code_Gcm_blocks alg offset) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CNil ())))))
val va_codegen_success_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_wrapped alg offset =
(va_pbool_and (va_codegen_success_Gcm_blocks alg offset) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks_wrapped (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 739 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b) (fun (va_s:va_state) _ -> va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(8 `op_Multiply` va_get_reg64 rRsi va_old_s >= 0 /\ 8 `op_Multiply` va_get_reg64 rRsi va_old_s
<= 18446744073709551615 /\ 8 `op_Multiply` plain_num_bytes >= 0 /\ 8 `op_Multiply`
plain_num_bytes <= 18446744073709551615) (fun _ -> let (va_arg55:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_old_s) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(va_arg54:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in let
(va_arg53:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s)) in let
(va_arg52:Vale.Def.Types_s.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (va_arg51:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg50:Prims.nat) =
va_get_reg64 rRsi va_old_s in let (va_arg49:Prims.nat) = plain_num_bytes in let
(va_arg48:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg47:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg46:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg45:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg44:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg43:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg42:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_old_s) abytes_b in let (va_arg41:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b in let
(va_arg40:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg39:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_dec_helper_simplified va_arg39 va_arg40 va_arg41
va_arg42 va_arg43 va_arg44 va_arg45 va_arg46 va_arg47 va_arg48 va_arg49 va_arg50 va_arg51
va_arg52 va_arg53 va_arg54 va_arg55) (let (auth_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s)
abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 751 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64
rRsi va_old_s)) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_old_s) in let (va_arg38:Vale.Def.Types_s.quad32) =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s) in let
(va_arg37:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg36:Prims.nat) = plain_num_bytes in
let (va_arg35:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = expected_tag in let
(va_arg34:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = auth_bytes in let
(va_arg33:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg32:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg31:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg30:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg29:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg28:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg27:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg26:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 752 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_helper_dec_simplified va_arg26 va_arg27 va_arg28
va_arg29 va_arg30 va_arg31 va_arg32 va_arg33 va_arg34 va_arg35 va_arg36 va_arg37 va_arg38)
(va_QEmpty (()))))))))
val va_lemma_Gcm_blocks_wrapped : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
iv:supported_iv_LE -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> hkeys_b:buffer128 -> expected_tag:(seq nat8)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_wrapped alg offset) va_s0 /\ va_get_ok
va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet
5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1
va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12
va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks_wrapped va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks_wrapped va_mods alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks_wrapped alg offset) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 588 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 711 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 712 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 713 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 714 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 715 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 718 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 719 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 721 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 723 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0)
abytes_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 724 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 725 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 726 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 727 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 728 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 737 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 plain_bytes < pow2_32)) (cipher_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
plain_bytes auth_bytes expected_tag))) (Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8
va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key) iv plain_bytes auth_bytes))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (expected_tag:(seq nat8))
(va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
sse_enabled /\ movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 32) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 48) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 64) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) auth_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1
(va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6
va_s0) in128x6_ptr in128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) out128x6_ptr out128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1
va_s0) in128_ptr in128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) out128_ptr out128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5
va_s0) inout_ptr inout_b 1 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128
(va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0)
hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv)) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) ==> va_k
va_sM (())))
val va_wpProof_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> auth_b:buffer128 ->
abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 ->
out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 -> iv:supported_iv_LE ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> expected_tag:(seq nat8) -> va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b
out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks_wrapped alg offset)
([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b
inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks_wrapped (va_code_Gcm_blocks_wrapped alg offset) va_s0
alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key
round_keys keys_b hkeys_b expected_tag in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks_wrapped (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(va_QProc (va_code_Gcm_blocks_wrapped alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks_wrapped alg offset
auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys
keys_b hkeys_b expected_tag) (va_wpProof_Gcm_blocks_wrapped alg offset auth_b abytes_b
in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b
expected_tag))
#pop-options
//--
//-- Gcm_blocks_decrypt_stdcall
#push-options "--z3rlimit 1600"
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_decrypt_stdcall win alg =
(va_Block (va_CCons (va_code_CreateHeaplets ()) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_code_Save_registers win) (va_CCons (if win then va_Block (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR9)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 0)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 8))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (224
+ 40 + 88)) (va_CNil ())))))))) else va_Block (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (64 + 8 + 72)) (va_CNil ())))
(va_CCons (va_code_Gcm_blocks_wrapped alg (Vale.X64.Decls.total_if #int win (224 + 56) (64 +
8))) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rR15) (va_op_reg_opr64_reg64 rRsp)
(Vale.X64.Decls.total_if #int win (224 + 40 + 96) (64 + 8 + 80))) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rR15) 0 Secret) (va_CCons (va_code_XmmEqual (va_op_xmm_xmm 0) (va_op_xmm_xmm 8)) (va_CCons
(va_Block (va_CNil ())) (va_CCons (va_Block (va_CNil ())) (va_CCons (va_code_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_CCons (va_code_Restore_registers
win) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_CCons
(va_code_DestroyHeaplets ()) (va_CNil ()))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_decrypt_stdcall win alg =
(va_pbool_and (va_codegen_success_CreateHeaplets ()) (va_pbool_and
(va_codegen_success_Save_registers win) (va_pbool_and (if win then va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR9)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsp) (224
+ 40 + 0)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR9)
(va_op_reg_opr64_reg64 rRsp) (224 + 40 + 8)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 88)) (va_ttrue ())))))))
else va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRbp)
(va_op_reg_opr64_reg64 rRsp) (64 + 8 + 72)) (va_ttrue ())) (va_pbool_and
(va_codegen_success_Gcm_blocks_wrapped alg (Vale.X64.Decls.total_if #int win (224 + 56) (64 +
8))) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR15)
(va_op_reg_opr64_reg64 rRsp) (Vale.X64.Decls.total_if #int win (224 + 40 + 96) (64 + 8 + 80)))
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm
0) (va_op_reg_opr64_reg64 rR15) 0 Secret) (va_pbool_and (va_codegen_success_XmmEqual
(va_op_xmm_xmm 0) (va_op_xmm_xmm 8)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_pbool_and
(va_codegen_success_Restore_registers win) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_pbool_and
(va_codegen_success_DestroyHeaplets ()) (va_ttrue ()))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks_decrypt_stdcall (va_mods:va_mods_t) (win:bool) (alg:algorithm)
(auth_b:buffer128) (auth_bytes:nat64) (auth_num:nat64) (keys_b:buffer128) (iv_b:buffer128)
(iv:supported_iv_LE) (hkeys_b:buffer128) (abytes_b:buffer128) (in128x6_b:buffer128)
(out128x6_b:buffer128) (len128x6_num:nat64) (in128_b:buffer128) (out128_b:buffer128)
(len128_num:nat64) (inout_b:buffer128) (cipher_num:nat64) (scratch_b:buffer128) (tag_b:buffer128)
(key:(seq nat32)) : (va_quickCode unit (va_code_Gcm_blocks_decrypt_stdcall win alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRcx va_s)
(fun _ -> va_get_reg64 rRdi va_s) in let (auth_num_bytes:(va_int_range 0 18446744073709551615))
= va_if win (fun _ -> va_get_reg64 rRdx va_s) (fun _ -> va_get_reg64 rRsi va_s) in let
(auth_len:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s)
(fun _ -> va_get_reg64 rRdx va_s) in let (keys_ptr:(va_int_range 0 18446744073709551615)) =
va_if win (fun _ -> va_get_reg64 rR9 va_s) (fun _ -> va_get_reg64 rRcx va_s) in let
(iv_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 32 + 8 + 0) (va_get_stack va_s)) (fun _
-> va_get_reg64 rR8 va_s) in let (xip:(va_int_range 0 18446744073709551615)) = va_if win (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 32 + 8 + 8) (va_get_stack va_s))
(fun _ -> va_get_reg64 rR9 va_s) in let (abytes_ptr:(va_int_range 0 18446744073709551615)) =
va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 16)
(va_get_stack va_s)) (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 0)
(va_get_stack va_s)) in let (in128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win
(fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 24) (va_get_stack va_s))
(fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 8) (va_get_stack va_s))
in let (out128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 32) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 16) (va_get_stack va_s)) in let
(len128x6:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 40) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 24) (va_get_stack va_s)) in let
(in128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 48) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 32) (va_get_stack va_s)) in let
(out128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 56) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 40) (va_get_stack va_s)) in let
(len128:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 64) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 48) (va_get_stack va_s)) in let
(inout_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 72) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 56) (va_get_stack va_s)) in let
(cipher_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 80) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 64) (va_get_stack va_s)) in let
(scratch_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 88) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 72) (va_get_stack va_s)) in let
(tag_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 40 + 96) (va_get_stack va_s)) (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + 8 + 80) (va_get_stack va_s)) in
va_QBind va_range1
"***** PRECONDITION NOT MET AT line 989 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_CreateHeaplets ([declare_buffer128 auth_b 1 Secret Immutable; declare_buffer128
abytes_b 7 Secret Immutable; declare_buffer128 in128x6_b 6 Secret Immutable; declare_buffer128
in128_b 1 Secret Immutable; declare_buffer128 hkeys_b 0 Secret Immutable; declare_buffer128
tag_b 0 Secret Immutable; declare_buffer128 keys_b 0 Secret Immutable; declare_buffer128 iv_b 2
Public Mutable; declare_buffer128 scratch_b 3 Secret Mutable; declare_buffer128 out128x6_b 6
Secret Mutable; declare_buffer128 out128_b 1 Secret Mutable; declare_buffer128 inout_b 5 Secret
Mutable])) (fun (va_s:va_state) _ -> va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1003 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (alg_10639:Vale.AES.AES_common_s.algorithm) (key_10640:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) (input_LE_10641:Vale.Def.Types_s.quad32) ->
Vale.AES.AES_s.is_aes_key_LE alg_10639 key_10640) alg key (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0)) (fun _ -> let (va_arg69:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)) in let (va_arg68:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s) hkeys_b in va_qPURE
va_range1
"***** PRECONDITION NOT MET AT line 1003 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hkeys_reqs_pub_priv va_arg68 va_arg69) (va_qAssert
va_range1
"***** PRECONDITION NOT MET AT line 1004 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 40) (va_get_stack va_s))
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1005 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 80) (va_get_stack va_s))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1006 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Save_registers win) (fun (va_s:va_state) _ -> va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1009 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qInlineIf va_mods win (qblock va_mods (fun (va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1011 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1012 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRsi) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1013 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR8)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1014 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR9)) (fun (va_s:va_state) _ ->
va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1015 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_s + 224 == va_get_reg64 rRsp va_old_s) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1016 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 224 + 40) (va_get_stack va_s))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1017 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR8) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 0))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1018 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR9) (va_op_reg_opr64_reg64 rRsp) (224 + 40 + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1019 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (224 + 40 +
88)) (va_QEmpty (())))))))))))) (qblock va_mods (fun (va_s:va_state) -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1023 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_s + 64 == va_get_reg64 rRsp va_old_s) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1024 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Stack_i.valid_src_stack64 (va_get_reg64 rRsp va_s + 64 + 80) (va_get_stack va_s))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1025 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbp) (va_op_reg_opr64_reg64 rRsp) (64 + 8 + 72))
(va_QEmpty (()))))))) (fun (va_s:va_state) va_g -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1028 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_wrapped alg (Vale.X64.Decls.total_if #int win (224 + 56) (64 + 8)) auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b iv scratch_b key
(Vale.X64.Decls.buffer128_as_seq (va_get_mem_heaplet 0 va_old_s) keys_b) keys_b hkeys_b
(Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem_heaplet
0 va_old_s)))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1048 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR15) (va_op_reg_opr64_reg64 rRsp)
(Vale.X64.Decls.total_if #int win (224 + 40 + 96) (64 + 8 + 80))) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1049 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 0) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rR15) 0 Secret tag_b 0) (fun (va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1050 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 0 va_s == Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem_heaplet 0 va_s))
(va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 1051 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 0 va_s == Vale.X64.Decls.buffer128_read tag_b 0 (va_get_mem_heaplet 0 va_old_s))
(let (alleged_tag_quad:quad32) = va_get_xmm 0 va_s in let (computed_tag:quad32) = va_get_xmm 8
va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 1054 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_XmmEqual (va_op_xmm_xmm 0) (va_op_xmm_xmm 8)) (fun (va_s:va_state) _ -> let
(auth_raw_quads:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s) abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1057 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0
auth_num_bytes) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 auth_num_bytes in let (cipher_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 1059 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0
cipher_num_bytes) (fun _ -> let (cipher_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 cipher_num_bytes in let (va_arg67:Vale.Def.Types_s.quad32) = computed_tag
in let (va_arg66:Vale.Def.Types_s.quad32) = alleged_tag_quad in let
(va_arg65:Vale.Def.Words_s.nat64) = va_get_reg64 rRax va_s in let (va_arg64:(FStar.Seq.Base.seq
Vale.Def.Words_s.nat8)) = auth_bytes in let (va_arg63:(FStar.Seq.Base.seq
Vale.Def.Words_s.nat8)) = cipher_bytes in let (va_arg62:Vale.AES.GCM_s.supported_iv_LE) = iv in
let (va_arg61:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) =
Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key in let
(va_arg60:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 1060 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.decrypt_helper va_arg60 va_arg61 va_arg62 va_arg63 va_arg64
va_arg65 va_arg66 va_arg67) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1066 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1067 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Restore_registers win (va_get_reg64 rRsp va_old_s) (va_get_xmm 6 va_old_s)
(va_get_xmm 7 va_old_s) (va_get_xmm 8 va_old_s) (va_get_xmm 9 va_old_s) (va_get_xmm 10
va_old_s) (va_get_xmm 11 va_old_s) (va_get_xmm 12 va_old_s) (va_get_xmm 13 va_old_s)
(va_get_xmm 14 va_old_s) (va_get_xmm 15 va_old_s)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1068 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRax) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 1070 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_DestroyHeaplets ()) (va_QEmpty (())))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks_decrypt_stdcall va_b0 va_s0 win alg auth_b auth_bytes auth_num keys_b iv_b
iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key =
let (va_mods:va_mods_t) = [va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax;
va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks_decrypt_stdcall va_mods win alg auth_b auth_bytes auth_num keys_b
iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num in128_b out128_b len128_num inout_b
cipher_num scratch_b tag_b key in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks_decrypt_stdcall win alg)
va_qc va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 764 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (auth_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _
-> va_get_reg64 rRcx va_s0) (fun _ -> va_get_reg64 rRdi va_s0) in let
(auth_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rRdx
va_s0) (fun _ -> va_get_reg64 rRsi va_s0) in let (auth_len:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> va_get_reg64 rR8 va_s0) (fun _ -> va_get_reg64
rRdx va_s0) in let (keys_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
va_get_reg64 rR9 va_s0) (fun _ -> va_get_reg64 rRcx va_s0) in let (iv_ptr:(va_int_range 0
18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + 32 + 8 + 0) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR8 va_s0) in let
(xip:(va_int_range 0 18446744073709551615)) = va_if win (fun _ -> Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + 32 + 8 + 8) (va_get_stack va_s0)) (fun _ -> va_get_reg64 rR9 va_s0)
in let (abytes_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 16) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 0) (va_get_stack va_s0)) in let
(in128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 24) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 8) (va_get_stack va_s0)) in let
(out128x6_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 32) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 16) (va_get_stack va_s0)) in
let (len128x6:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 40) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 24) (va_get_stack va_s0)) in
let (in128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 48) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 32) (va_get_stack va_s0)) in
let (out128_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 56) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 40) (va_get_stack va_s0)) in
let (len128:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 64) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 48) (va_get_stack va_s0)) in
let (inout_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 72) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 56) (va_get_stack va_s0)) in
let (cipher_num_bytes:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 80) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 64) (va_get_stack va_s0)) in
let (scratch_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 88) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 72) (va_get_stack va_s0)) in
let (tag_ptr:(va_int_range 0 18446744073709551615)) = va_if win (fun _ ->
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 40 + 96) (va_get_stack va_s0)) (fun _
-> Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + 8 + 80) (va_get_stack va_s0)) in
label va_range1
"***** POSTCONDITION NOT MET AT line 931 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_mem (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer
#Vale.X64.Memory.vuint128 iv_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer
#Vale.X64.Memory.vuint128 scratch_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer
#Vale.X64.Memory.vuint128 out128x6_b) (Vale.X64.Decls.loc_union (Vale.X64.Decls.loc_buffer
#Vale.X64.Memory.vuint128 out128_b) (Vale.X64.Decls.loc_buffer #Vale.X64.Memory.vuint128
inout_b))))) (va_get_mem va_s0) (va_get_mem va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 934 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(cipher_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 935 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(auth_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 937 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem va_s0) in label va_range1
"***** POSTCONDITION NOT MET AT line 939 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem va_s0) abytes_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 940 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 auth_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 941 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_s0) in128_b)) (Vale.X64.Decls.s128 (va_get_mem va_s0) inout_b) in label
va_range1
"***** POSTCONDITION NOT MET AT line 942 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 cipher_num_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 943 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem va_sM) inout_b) in label
va_range1
"***** POSTCONDITION NOT MET AT line 944 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 cipher_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 945 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let expected_tag = Vale.Def.Types_s.le_quad32_to_bytes (Vale.X64.Decls.buffer128_read tag_b 0
(va_get_mem va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 955 column 71 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 cipher_bytes < pow2_32))
(Vale.AES.AES_common_s.is_aes_key alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)))
(plain_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) (va_get_reg64 rRax va_sM = 0 ==
__proj__Mktuple2__item___2 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
cipher_bytes auth_bytes expected_tag))) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 958 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsp va_sM == va_get_reg64 rRsp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 961 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 962 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 963 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rRdi va_sM == va_get_reg64 rRdi va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 964 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rRsi va_sM == va_get_reg64 rRsi va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 965 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 966 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 967 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 968 column 32 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 970 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 6 va_sM == va_get_xmm 6 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 971 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 7 va_sM == va_get_xmm 7 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 972 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 8 va_sM == va_get_xmm 8 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 973 column 35 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 9 va_sM == va_get_xmm 9 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 974 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 10 va_sM == va_get_xmm 10 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 975 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 11 va_sM == va_get_xmm 11 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 976 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 12 va_sM == va_get_xmm 12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 977 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 13 va_sM == va_get_xmm 13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 978 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 14 va_sM == va_get_xmm 14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 979 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(win ==> va_get_xmm 15 va_sM == va_get_xmm 15 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 982 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rRbx va_sM == va_get_reg64 rRbx va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 983 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rRbp va_sM == va_get_reg64 rRbp va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 984 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rR12 va_sM == va_get_reg64 rR12 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 985 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rR13 va_sM == va_get_reg64 rR13 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 986 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rR14 va_sM == va_get_reg64 rR14 va_s0) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 987 column 33 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(~win ==> va_get_reg64 rR15 va_sM == va_get_reg64 rR15 va_s0))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax;
va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"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.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"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.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.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": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 1600,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
win: Prims.bool ->
alg: Vale.AES.AES_common_s.algorithm ->
auth_b: Vale.X64.Memory.buffer128 ->
auth_bytes: Vale.X64.Memory.nat64 ->
auth_num: Vale.X64.Memory.nat64 ->
keys_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
hkeys_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
len128x6_num: Vale.X64.Memory.nat64 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
len128_num: Vale.X64.Memory.nat64 ->
inout_b: Vale.X64.Memory.buffer128 ->
cipher_num: Vale.X64.Memory.nat64 ->
scratch_b: Vale.X64.Memory.buffer128 ->
tag_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Prims.Ghost ((Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) * Prims.unit) | Prims.Ghost | [] | [] | [
"Prims.bool",
"Vale.AES.AES_common_s.algorithm",
"Vale.X64.Memory.buffer128",
"Vale.X64.Memory.nat64",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Vale.X64.Decls.va_fuel",
"FStar.Pervasives.Native.Mktuple3",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_stackTaint",
"Vale.X64.QuickCode.va_Mod_stack",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_layout",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"Prims._assert",
"Vale.X64.Decls.va_state_eq",
"Vale.X64.Decls.va_update_stackTaint",
"Vale.X64.Decls.va_update_stack",
"Vale.X64.Decls.va_update_flags",
"Vale.X64.Decls.va_update_mem_layout",
"Vale.X64.Decls.va_update_mem_heaplet",
"Vale.X64.Decls.va_update_xmm",
"Vale.X64.Decls.va_update_reg64",
"Vale.X64.Decls.va_update_ok",
"Vale.X64.Decls.va_update_mem",
"Vale.X64.Decls.va_lemma_upd_update",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.tuple2",
"Vale.X64.State.vale_state",
"Vale.AES.X64.GCMdecryptOpt.va_lemma_Gcm_blocks_decrypt_stdcall",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_decrypt_stdcall"
] | [] | false | false | false | false | false | let va_wpProof_Gcm_blocks_decrypt_stdcall
win
alg
auth_b
auth_bytes
auth_num
keys_b
iv_b
iv
hkeys_b
abytes_b
in128x6_b
out128x6_b
len128x6_num
in128_b
out128_b
len128_num
inout_b
cipher_num
scratch_b
tag_b
key
va_s0
va_k
=
| let va_sM, va_f0 =
va_lemma_Gcm_blocks_decrypt_stdcall (va_code_Gcm_blocks_decrypt_stdcall win alg) va_s0 win alg
auth_b auth_bytes auth_num keys_b iv_b iv hkeys_b abytes_b in128x6_b out128x6_b len128x6_num
in128_b out128_b len128_num inout_b cipher_num scratch_b tag_b key
in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM
(va_update_stackTaint va_sM
(va_update_stack va_sM
(va_update_flags va_sM
(va_update_mem_layout va_sM
(va_update_mem_heaplet 6
va_sM
(va_update_mem_heaplet 5
va_sM
(va_update_mem_heaplet 3
va_sM
(va_update_mem_heaplet 2
va_sM
(va_update_mem_heaplet 1
va_sM
(va_update_xmm 15
va_sM
(va_update_xmm 14
va_sM
(va_update_xmm 13
va_sM
(va_update_xmm 12
va_sM
(va_update_xmm 11
va_sM
(va_update_xmm 10
va_sM
(va_update_xmm 9
va_sM
(va_update_xmm 8
va_sM
(va_update_xmm 7
va_sM
(va_update_xmm 6
va_sM
(va_update_xmm 5
va_sM
(va_update_xmm
4
va_sM
(va_update_xmm
3
va_sM
(va_update_xmm
2
va_sM
(va_update_xmm
1
va_sM
(
va_update_xmm
0
va_sM
(
va_update_reg64
rR15
va_sM
(
va_update_reg64
rR14
va_sM
(
va_update_reg64
rR13
va_sM
(
va_update_reg64
rR12
va_sM
(
va_update_reg64
rR11
va_sM
(
va_update_reg64
rR10
va_sM
(
va_update_reg64
rR9
va_sM
(
va_update_reg64
rR8
va_sM
(
va_update_reg64
rRbp
va_sM
(
va_update_reg64
rRsp
va_sM
(
va_update_reg64
rRsi
va_sM
(
va_update_reg64
rRdi
va_sM
(
va_update_reg64
rRdx
va_sM
(
va_update_reg64
rRcx
va_sM
(
va_update_reg64
rRbx
va_sM
(
va_update_reg64
rRax
va_sM
(
va_update_ok
va_sM
(
va_update_mem
va_sM
va_s0
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
))
))))))))))
)))))))))))));
va_lemma_norm_mods ([
va_Mod_stackTaint; va_Mod_stack; va_Mod_flags; va_Mod_mem_layout; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4;
va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14;
va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9;
va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem
])
va_sM
va_s0;
let va_g = () in
(va_sM, va_f0, va_g) | false |
AlgHeap.fst | AlgHeap.lift_pure_eff | val lift_pure_eff (a: Type) (wp: pure_wp a) (f: (unit -> PURE a wp))
: Pure (tree a []) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) | val lift_pure_eff (a: Type) (wp: pure_wp a) (f: (unit -> PURE a wp))
: Pure (tree a []) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) | let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ()) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 16,
"end_line": 197,
"start_col": 0,
"start_line": 189
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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: Prims.pure_wp a -> f: (_: Prims.unit -> Prims.PURE a)
-> Prims.Pure (AlgHeap.tree a []) | Prims.Pure | [] | [] | [
"Prims.pure_wp",
"Prims.unit",
"AlgHeap.Return",
"FStar.Monotonic.Pure.elim_pure_wp_monotonicity",
"AlgHeap.tree",
"Prims.Nil",
"AlgHeap.op",
"Prims.l_True"
] | [] | false | false | false | false | false | let lift_pure_eff (a: Type) (wp: pure_wp a) (f: (unit -> PURE a wp))
: Pure (tree a []) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) =
| FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ()) | false |
AlgHeap.fst | AlgHeap.modifies | val modifies (ls: list loc) (h0 h1: state) : Type0 | val modifies (ls: list loc) (h0 h1: state) : Type0 | let modifies (ls: list loc) (h0 h1 : state) : Type0 =
forall y. mem y ls \/ (Map.sel h0 y == Map.sel h1 y) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 54,
"end_line": 417,
"start_col": 0,
"start_line": 416
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp
let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r
let upd (r:loc) (v:int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
let h = get2 () in
put2 (Map.upd h r v)
let (!) = sel
let (:=) = upd
let modifies1 (l:loc) (h0 h1 : state) : Type0 =
forall y. y <> l ==> Map.sel h0 y == Map.sel h1 y | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | ls: Prims.list AlgHeap.loc -> h0: AlgHeap.state -> h1: AlgHeap.state -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Prims.list",
"AlgHeap.loc",
"AlgHeap.state",
"Prims.l_Forall",
"Prims.l_or",
"Prims.b2t",
"FStar.List.Tot.Base.mem",
"Prims.eq2",
"Prims.int",
"FStar.Map.sel"
] | [] | false | false | false | true | true | let modifies (ls: list loc) (h0 h1: state) : Type0 =
| forall y. mem y ls \/ (Map.sel h0 y == Map.sel h1 y) | false |
SolveThen.fst | SolveThen.constr | val constr (a b: prop) : squash (a ==> b ==> b /\ a) | val constr (a b: prop) : squash (a ==> b ==> b /\ a) | let constr (a b : prop) : squash (a ==> b ==> b /\ a)
= _ by
(let ha = implies_intro () in
let hb = implies_intro () in
split ();
hyp (binding_to_namedv hb);
hyp (binding_to_namedv ha);
qed ()) | {
"file_name": "examples/tactics/SolveThen.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 15,
"end_line": 34,
"start_col": 0,
"start_line": 27
} | (*
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 SolveThen
open FStar.Tactics.V2
let rec fib n : Tac unit = if n < 2 then exact (`1) else (apply (`(+)); fib (n - 1); fib (n - 2))
let f3 : int = _ by (fib 3)
let f8 : int = _ by (solve_then (fun () -> fib 8) compute) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "SolveThen.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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.prop -> b: Prims.prop -> Prims.squash (a ==> b ==> b /\ a) | Prims.Tot | [
"total"
] | [] | [
"Prims.prop",
"Prims.squash",
"Prims.l_imp",
"Prims.l_and"
] | [] | false | false | true | false | false | let constr (a b: prop) : squash (a ==> b ==> b /\ a) =
| FStar.Tactics.Effect.synth_by_tactic (fun _ ->
(let ha = implies_intro () in
let hb = implies_intro () in
split ();
hyp (binding_to_namedv hb);
hyp (binding_to_namedv ha);
qed ())) | false |
AlgHeap.fst | AlgHeap.write_wp | val write_wp: state -> st_wp unit | val write_wp: state -> st_wp unit | let write_wp : state -> st_wp unit = fun s _ p -> p ((), s) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 59,
"end_line": 235,
"start_col": 0,
"start_line": 235
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | s: AlgHeap.state -> AlgHeap.st_wp Prims.unit | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.state",
"FStar.Pervasives.Native.tuple2",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2"
] | [] | false | false | false | true | false | let write_wp: state -> st_wp unit =
| fun s _ p -> p ((), s) | false |
AlgHeap.fst | AlgHeap.modifies1 | val modifies1 (l: loc) (h0 h1: state) : Type0 | val modifies1 (l: loc) (h0 h1: state) : Type0 | let modifies1 (l:loc) (h0 h1 : state) : Type0 =
forall y. y <> l ==> Map.sel h0 y == Map.sel h1 y | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 51,
"end_line": 414,
"start_col": 0,
"start_line": 413
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp
let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r
let upd (r:loc) (v:int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
let h = get2 () in
put2 (Map.upd h r v)
let (!) = sel
let (:=) = upd | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | l: AlgHeap.loc -> h0: AlgHeap.state -> h1: AlgHeap.state -> Type0 | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.loc",
"AlgHeap.state",
"Prims.l_Forall",
"Prims.l_imp",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.eq2",
"Prims.int",
"FStar.Map.sel"
] | [] | false | false | false | true | true | let modifies1 (l: loc) (h0 h1: state) : Type0 =
| forall y. y <> l ==> Map.sel h0 y == Map.sel h1 y | false |
SolveThen.fst | SolveThen.f8 | val f8:int | val f8:int | let f8 : int = _ by (solve_then (fun () -> fib 8) compute) | {
"file_name": "examples/tactics/SolveThen.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 58,
"end_line": 24,
"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 SolveThen
open FStar.Tactics.V2
let rec fib n : Tac unit = if n < 2 then exact (`1) else (apply (`(+)); fib (n - 1); fib (n - 2))
let f3 : int = _ by (fib 3) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Tactics.Effect.fsti.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": false,
"source_file": "SolveThen.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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.int | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let f8:int =
| FStar.Tactics.Effect.synth_by_tactic (fun _ -> (solve_then (fun () -> fib 8) compute)) | false |
AlgHeap.fst | AlgHeap.read_wp | val read_wp:st_wp state | val read_wp:st_wp state | let read_wp : st_wp state = fun s0 p -> p (s0, s0) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 50,
"end_line": 232,
"start_col": 0,
"start_line": 232
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | AlgHeap.st_wp AlgHeap.state | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.state",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2"
] | [] | false | false | false | true | false | let read_wp:st_wp state =
| fun s0 p -> p (s0, s0) | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_lemma_Gcm_blocks_wrapped | val va_lemma_Gcm_blocks_wrapped : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
iv:supported_iv_LE -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> hkeys_b:buffer128 -> expected_tag:(seq nat8)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_wrapped alg offset) va_s0 /\ va_get_ok
va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet
5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1
va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12
va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))))))))) | val va_lemma_Gcm_blocks_wrapped : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
iv:supported_iv_LE -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> hkeys_b:buffer128 -> expected_tag:(seq nat8)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_wrapped alg offset) va_s0 /\ va_get_ok
va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet
5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1
va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12
va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))))))))) | let va_lemma_Gcm_blocks_wrapped va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks_wrapped va_mods alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks_wrapped alg offset) va_qc
va_s0 (fun va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 588 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 711 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 712 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 713 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 714 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 715 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 718 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 719 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 721 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 723 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0)
abytes_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 724 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 725 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 726 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 727 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 728 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads) 0 plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 737 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8 auth_bytes < pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8 plain_bytes < pow2_32)) (cipher_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8) #bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv
plain_bytes auth_bytes expected_tag))) (Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8
va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key) iv plain_bytes auth_bytes))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 16,
"end_line": 1691,
"start_col": 0,
"start_line": 1598
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE:quad32 ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks : alg:algorithm -> offset:int -> auth_b:buffer128 -> abytes_b:buffer128
-> in128x6_b:buffer128 -> out128x6_b:buffer128 -> in128_b:buffer128 -> out128_b:buffer128 ->
inout_b:buffer128 -> iv_b:buffer128 -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq
quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit ->
Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b
in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks alg offset) ([va_Mod_flags;
va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2;
va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm
11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15;
va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10;
va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi;
va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) va_s0
va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks (va_code_Gcm_blocks alg offset) va_s0 alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0))))))))))))))))))))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_Gcm_blocks alg
offset)) =
(va_QProc (va_code_Gcm_blocks alg offset) ([va_Mod_flags; va_Mod_mem_heaplet 6;
va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1;
va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10;
va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64
rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64
rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64
rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_Gcm_blocks alg offset auth_b
abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b key round_keys keys_b
hkeys_b) (va_wpProof_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b))
#pop-options
//--
//-- Gcm_blocks_wrapped
#push-options "--z3rlimit 60"
val va_code_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks_wrapped alg offset =
(va_Block (va_CCons (va_code_Gcm_blocks alg offset) (va_CCons (va_Block (va_CNil ())) (va_CCons
(va_Block (va_CNil ())) (va_CNil ())))))
val va_codegen_success_Gcm_blocks_wrapped : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks_wrapped alg offset =
(va_pbool_and (va_codegen_success_Gcm_blocks alg offset) (va_ttrue ()))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks_wrapped (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (iv:supported_iv_LE)
(scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128)
(hkeys_b:buffer128) (expected_tag:(seq nat8)) : (va_quickCode unit (va_code_Gcm_blocks_wrapped
alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 739 column 15 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks alg offset auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b
iv_b scratch_b key round_keys keys_b hkeys_b) (fun (va_s:va_state) _ -> va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(8 `op_Multiply` va_get_reg64 rRsi va_old_s >= 0 /\ 8 `op_Multiply` va_get_reg64 rRsi va_old_s
<= 18446744073709551615 /\ 8 `op_Multiply` plain_num_bytes >= 0 /\ 8 `op_Multiply`
plain_num_bytes <= 18446744073709551615) (fun _ -> let (va_arg55:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_old_s) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(va_arg54:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in let
(va_arg53:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s)) in let
(va_arg52:Vale.Def.Types_s.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (va_arg51:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg50:Prims.nat) =
va_get_reg64 rRsi va_old_s in let (va_arg49:Prims.nat) = plain_num_bytes in let
(va_arg48:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg47:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg46:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg45:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg44:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg43:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg42:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_old_s) abytes_b in let (va_arg41:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) auth_b in let
(va_arg40:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg39:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 741 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_dec_helper_simplified va_arg39 va_arg40 va_arg41
va_arg42 va_arg43 va_arg44 va_arg45 va_arg46 va_arg47 va_arg48 va_arg49 va_arg50 va_arg51
va_arg52 va_arg53 va_arg54 va_arg55) (let (auth_raw_quads:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) auth_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_old_s)
abytes_b) in va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 751 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads) 0 (va_get_reg64
rRsi va_old_s)) (fun _ -> let (auth_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_old_s) in let (va_arg38:Vale.Def.Types_s.quad32) =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_old_s) in let
(va_arg37:Vale.AES.GCM_s.supported_iv_LE) = iv in let (va_arg36:Prims.nat) = plain_num_bytes in
let (va_arg35:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = expected_tag in let
(va_arg34:(FStar.Seq.Base.seq Vale.Def.Words_s.nat8)) = auth_bytes in let
(va_arg33:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s) inout_b in let (va_arg32:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg31:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s) out128x6_b in let (va_arg30:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let
(va_arg29:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg28:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in
let (va_arg27:(FStar.Seq.Base.seq Vale.Def.Words_s.nat32)) = key in let
(va_arg26:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 752 column 37 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCM.gcm_blocks_helper_dec_simplified va_arg26 va_arg27 va_arg28
va_arg29 va_arg30 va_arg31 va_arg32 va_arg33 va_arg34 va_arg35 va_arg36 va_arg37 va_arg38)
(va_QEmpty (()))))))))
val va_lemma_Gcm_blocks_wrapped : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
iv:supported_iv_LE -> scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) ->
keys_b:buffer128 -> hkeys_b:buffer128 -> expected_tag:(seq nat8)
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks_wrapped alg offset) va_s0 /\ va_get_ok
va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64
rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))) /\ (let iv_BE =
Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let h_LE =
Vale.AES.AES_s.aes_encrypt_LE alg key (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
in iv_BE == Vale.AES.GCM_s.compute_iv_BE h_LE iv))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128
iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM) /\ Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0
(va_get_mem_heaplet 2 va_s0) in let auth_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b) in let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
auth_raw_quads) 0 (va_get_reg64 rRsi va_s0) in let plain_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
in128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) in let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
plain_raw_quads) 0 plain_num_bytes in let cipher_raw_quads = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) in let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
cipher_raw_quads) 0 plain_num_bytes in l_and (l_and (l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.nat8 auth_bytes < pow2_32) (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes < pow2_32)) (cipher_bytes == __proj__Mktuple2__item___1 #(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8) #bool (Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM) == Vale.AES.GCM.gcm_decrypt_LE_tag
alg (Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key) iv plain_bytes auth_bytes))) /\
va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM (va_update_mem_heaplet
5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 1
va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12
va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM
(va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM (va_update_reg64 rRbp va_sM
(va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRdx va_sM
(va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRax va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0))))))))))))))))))))))))))))))))))))))))) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"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.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"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.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.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": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 60,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
va_b0: Vale.X64.Decls.va_code ->
va_s0: Vale.X64.Decls.va_state ->
alg: Vale.AES.AES_common_s.algorithm ->
offset: Prims.int ->
auth_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
inout_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
iv: Vale.AES.GCM_s.supported_iv_LE ->
scratch_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128 ->
expected_tag: FStar.Seq.Base.seq Vale.X64.Memory.nat8
-> Prims.Ghost (Vale.X64.Decls.va_state * Vale.X64.Decls.va_fuel) | Prims.Ghost | [] | [] | [
"Vale.X64.Decls.va_code",
"Vale.X64.Decls.va_state",
"Vale.AES.AES_common_s.algorithm",
"Prims.int",
"Vale.X64.Memory.buffer128",
"Vale.AES.GCM_s.supported_iv_LE",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.Memory.nat8",
"Vale.X64.QuickCodes.fuel",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Vale.X64.Decls.va_fuel",
"Vale.X64.QuickCode.va_lemma_norm_mods",
"Prims.Cons",
"Vale.X64.QuickCode.mod_t",
"Vale.X64.QuickCode.va_Mod_flags",
"Vale.X64.QuickCode.va_Mod_mem_heaplet",
"Vale.X64.QuickCode.va_Mod_xmm",
"Vale.X64.QuickCode.va_Mod_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.QuickCode.va_Mod_ok",
"Vale.X64.QuickCode.va_Mod_mem",
"Prims.Nil",
"FStar.Pervasives.assert_norm",
"Prims.eq2",
"Prims.list",
"Vale.X64.QuickCode.__proj__QProc__item__mods",
"Vale.AES.X64.GCMdecryptOpt.va_code_Gcm_blocks_wrapped",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.tuple3",
"Vale.X64.State.vale_state",
"Vale.X64.QuickCodes.va_wp_sound_code_norm",
"Prims.l_and",
"Vale.X64.QuickCodes.label",
"Vale.X64.QuickCodes.va_range1",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.Decls.modifies_buffer128",
"Vale.X64.Decls.va_get_mem_heaplet",
"Prims.op_LessThan",
"Vale.X64.Machine_s.pow2_32",
"Vale.X64.Decls.va_get_reg64",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.nat8",
"FStar.Pervasives.Native.__proj__Mktuple2__item___1",
"Prims.bool",
"Vale.AES.GCM_s.gcm_decrypt_LE",
"Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE",
"Vale.Def.Words_s.nat8",
"Vale.Def.Types_s.le_quad32_to_bytes",
"Vale.X64.Decls.va_get_xmm",
"Vale.AES.GCM.gcm_decrypt_LE_tag",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Vale.Def.Types_s.quad32",
"FStar.Seq.Base.append",
"Vale.X64.Decls.s128",
"Vale.X64.Decls.buffer128_read",
"Vale.Def.Words_s.nat64",
"Vale.X64.Stack_i.load_stack64",
"Prims.op_Addition",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Decls.va_get_stack",
"Vale.X64.QuickCode.quickCode",
"Vale.AES.X64.GCMdecryptOpt.va_qcode_Gcm_blocks_wrapped"
] | [] | false | false | false | false | false | let va_lemma_Gcm_blocks_wrapped
va_b0
va_s0
alg
offset
auth_b
abytes_b
in128x6_b
out128x6_b
in128_b
out128_b
inout_b
iv_b
iv
scratch_b
key
round_keys
keys_b
hkeys_b
expected_tag
=
| let va_mods:va_mods_t =
[
va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11;
va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64 rRsi;
va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64 rRax;
va_Mod_ok; va_Mod_mem
]
in
let va_qc =
va_qcode_Gcm_blocks_wrapped va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b iv scratch_b key round_keys keys_b hkeys_b expected_tag
in
let va_sM, va_fM, va_g =
va_wp_sound_code_norm (va_code_Gcm_blocks_wrapped alg offset)
va_qc
va_s0
(fun va_s0 va_sM va_g ->
let () = va_g in
label va_range1
"***** POSTCONDITION NOT MET AT line 588 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\
(let abytes_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0)
in
let in128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8)
(va_get_stack va_s0)
in
let out128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16)
(va_get_stack va_s0)
in
let len128x6:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24)
(va_get_stack va_s0)
in
let in128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32)
(va_get_stack va_s0)
in
let out128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40)
(va_get_stack va_s0)
in
let len128:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48)
(va_get_stack va_s0)
in
let inout_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56)
(va_get_stack va_s0)
in
let plain_num_bytes:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64)
(va_get_stack va_s0)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 711 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 712 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 713 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b
(va_get_mem_heaplet 3 va_s0)
(va_get_mem_heaplet 3 va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 714 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 715 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM)) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 718 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 719 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\
label va_range1
"***** POSTCONDITION NOT MET AT line 721 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in
label va_range1
"***** POSTCONDITION NOT MET AT line 723 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 724 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let auth_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes auth_raw_quads)
0
(va_get_reg64 rRsi va_s0)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 725 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 726 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let plain_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes plain_raw_quads)
0
plain_num_bytes
in
label va_range1
"***** POSTCONDITION NOT MET AT line 727 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_raw_quads =
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b
))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b)
in
label va_range1
"***** POSTCONDITION NOT MET AT line 728 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let cipher_bytes =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes cipher_raw_quads)
0
plain_num_bytes
in
label va_range1
"***** POSTCONDITION NOT MET AT line 737 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (l_and (l_and (FStar.Seq.Base.length #Vale.Def.Types_s.nat8
auth_bytes <
pow2_32)
(FStar.Seq.Base.length #Vale.Def.Types_s.nat8
plain_bytes <
pow2_32))
(cipher_bytes ==
__proj__Mktuple2__item___1 #(FStar.Seq.Base.seq Vale.Def.Types_s.nat8
)
#bool
(Vale.AES.GCM_s.gcm_decrypt_LE alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE
key)
iv
plain_bytes
auth_bytes
expected_tag)))
(Vale.Def.Types_s.le_quad32_to_bytes (va_get_xmm 8 va_sM
) ==
Vale.AES.GCM.gcm_decrypt_LE_tag alg
(Vale.Def.Words.Seq_s.seq_nat32_to_seq_nat8_LE key)
iv
plain_bytes
auth_bytes)))))))))))
in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([
va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet 3;
va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem
])
va_sM
va_s0;
(va_sM, va_fM) | false |
AlgHeap.fst | AlgHeap.bind_wp | val bind_wp (#a #b: _) (w: st_wp a) (wf: (a -> st_wp b)) : st_wp b | val bind_wp (#a #b: _) (w: st_wp a) (wf: (a -> st_wp b)) : st_wp b | let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 47,
"end_line": 229,
"start_col": 0,
"start_line": 227
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | w: AlgHeap.st_wp a -> wf: (_: a -> AlgHeap.st_wp b) -> AlgHeap.st_wp b | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.st_wp",
"AlgHeap.state",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | true | false | let bind_wp #a #b (w: st_wp a) (wf: (a -> st_wp b)) : st_wp b =
| fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p) | false |
AlgHeap.fst | AlgHeap.interp_as_wp | val interp_as_wp (#a: _) (t: rwtree a) : st_wp a | val interp_as_wp (#a: _) (t: rwtree a) : st_wp a | let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o)) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 61,
"end_line": 244,
"start_col": 0,
"start_line": 238
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | t: AlgHeap.rwtree a -> AlgHeap.st_wp a | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.rwtree",
"AlgHeap.return_wp",
"AlgHeap.op_inp",
"AlgHeap.Read",
"AlgHeap.op_out",
"AlgHeap.tree0",
"AlgHeap.bind_wp",
"AlgHeap.state",
"AlgHeap.read_wp",
"AlgHeap.interp_as_wp",
"AlgHeap.st_wp",
"AlgHeap.Write",
"Prims.unit",
"AlgHeap.write_wp"
] | [
"recursion"
] | false | false | false | true | false | let rec interp_as_wp #a (t: rwtree a) : st_wp a =
| match t with
| Return x -> return_wp x
| Op Read _ k -> bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k -> bind_wp (write_wp s) (fun (o: unit) -> interp_as_wp (k o)) | false |
Vale.Inline.X64.Fadd_inline.fst | Vale.Inline.X64.Fadd_inline.fsub | val fsub
(out:u256)
(f1:u256)
(f2:u256)
: Stack unit
(requires fun h ->
adx_enabled /\ bmi2_enabled /\
B.live h f1 /\ B.live h f2 /\ B.live h out /\
(B.disjoint out f1 \/ out == f1) /\
(B.disjoint out f2 \/ out == f2) /\
(B.disjoint f1 f2 \/ f1 == f2))
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer out) h0 h1 /\
(as_nat out h1) % prime == (as_nat f1 h0 - as_nat f2 h0) % prime) | val fsub
(out:u256)
(f1:u256)
(f2:u256)
: Stack unit
(requires fun h ->
adx_enabled /\ bmi2_enabled /\
B.live h f1 /\ B.live h f2 /\ B.live h out /\
(B.disjoint out f1 \/ out == f1) /\
(B.disjoint out f2 \/ out == f2) /\
(B.disjoint f1 f2 \/ f1 == f2))
(ensures fun h0 _ h1 ->
B.modifies (B.loc_buffer out) h0 h1 /\
(as_nat out h1) % prime == (as_nat f1 h0 - as_nat f2 h0) % prime) | let fsub out f1 f2
= DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
DV.length_eq (get_downview f2);
let (x, _) = lowstar_Fsub_normal_t out f1 f2 () in
() | {
"file_name": "vale/code/arch/x64/interop/Vale.Inline.X64.Fadd_inline.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 410,
"start_col": 0,
"start_line": 405
} | module Vale.Inline.X64.Fadd_inline
open FStar.Mul
open FStar.HyperStack.ST
module HS = FStar.HyperStack
module B = LowStar.Buffer
module DV = LowStar.BufferView.Down
open Vale.Def.Types_s
open Vale.Interop.Base
module IX64 = Vale.Interop.X64
module VSig = Vale.AsLowStar.ValeSig
module LSig = Vale.AsLowStar.LowStarSig
module ME = Vale.X64.Memory
module V = Vale.X64.Decls
module IA = Vale.Interop.Assumptions
module W = Vale.AsLowStar.Wrapper
open Vale.X64.MemoryAdapters
module VS = Vale.X64.State
module MS = Vale.X64.Machine_s
module PR = Vale.X64.Print_Inline_s
module FU = Vale.Curve25519.X64.FastUtil
module FH = Vale.Curve25519.X64.FastHybrid
module FW = Vale.Curve25519.X64.FastWide
let uint64 = UInt64.t
(* A little utility to trigger normalization in types *)
let as_t (#a:Type) (x:normal a) : a = x
let as_normal_t (#a:Type) (x:a) : normal a = x
[@__reduce__]
let b64 = buf_t TUInt64 TUInt64
[@__reduce__]
let t64_mod = TD_Buffer TUInt64 TUInt64 default_bq
[@__reduce__]
let t64_no_mod = TD_Buffer TUInt64 TUInt64 ({modified=false; strict_disjointness=false; taint=MS.Secret})
[@__reduce__]
let tuint64 = TD_Base TUInt64
[@__reduce__]
let dom: IX64.arity_ok 3 td =
let y = [t64_mod; t64_no_mod; tuint64] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let add1_pre : VSig.vale_pre dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state) ->
FU.va_req_Fast_add1 c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2)
[@__reduce__]
let add1_post : VSig.vale_post dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FU.va_ens_Fast_add1 c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) va_s1 f
#set-options "--z3rlimit 50"
let add1_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let add1_xmms_modified = fun _ -> false
[@__reduce__]
let add1_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:uint64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
add1_pre code out f1 f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 add1_regs_modified add1_xmms_modified /\
add1_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FU.va_lemma_Fast_add1 code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (UInt64.v f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let add1_lemma = as_t #(VSig.vale_sig add1_regs_modified add1_xmms_modified add1_pre add1_post) add1_lemma'
let code_add1 = FU.va_code_Fast_add1 ()
let of_reg (r:MS.reg_64) : option (IX64.reg_nat 3) = match r with
| 5 -> Some 0 // rdi
| 4 -> Some 1 // rsi
| 3 -> Some 2 // rdx
| _ -> None
let of_arg (i:IX64.reg_nat 3) : MS.reg_64 = match i with
| 0 -> MS.rRdi
| 1 -> MS.rRsi
| 2 -> MS.rRdx
let arg_reg : IX64.arg_reg_relation 3 = IX64.Rel of_reg of_arg
(* Here's the type expected for the add1 wrapper *)
[@__reduce__]
let lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
(* And here's the add1 wrapper itself *)
let lowstar_add1 : lowstar_add1_t =
assert_norm (List.length dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
add1_regs_modified
add1_xmms_modified
code_add1
dom
(W.mk_prediction code_add1 dom [] (add1_lemma code_add1 IA.win))
let lowstar_add1_normal_t : normal lowstar_add1_t
= as_normal_t #lowstar_add1_t lowstar_add1
open Vale.AsLowStar.MemoryHelpers
let add_scalar out f1 f2
= DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
let (x, _) = lowstar_add1_normal_t out f1 f2 () in
x
let add1_comments : list string =
["Computes the addition of four-element f1 with value in f2"; "and returns the carry (if any)"]
let add1_names (n:nat) =
match n with
| 0 -> "out"
| 1 -> "f1"
| 2 -> "f2"
| _ -> ""
let add1_code_inline () : FStar.All.ML int =
PR.print_inline "add_scalar" 0 None (List.length dom) dom add1_names code_add1 of_arg add1_regs_modified add1_comments
[@__reduce__]
let fadd_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_no_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let fadd_pre : VSig.vale_pre fadd_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state) ->
FH.va_req_Fadd c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
[@__reduce__]
let fadd_post : VSig.vale_post fadd_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FH.va_ens_Fadd c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 50"
let fadd_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRcx || r = rRdx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let fadd_xmms_modified = fun _ -> false
[@__reduce__]
let fadd_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fadd_pre code out f1 f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 fadd_regs_modified fadd_xmms_modified /\
fadd_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FH.va_lemma_Fadd code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
(va_s1, f)
(* Prove that add1_lemma' has the required type *)
let fadd_lemma = as_t #(VSig.vale_sig fadd_regs_modified fadd_xmms_modified fadd_pre fadd_post) fadd_lemma'
let code_Fadd = FH.va_code_Fadd ()
(* Here's the type expected for the fadd wrapper *)
[@__reduce__]
let lowstar_fadd_t =
assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
fadd_regs_modified
fadd_xmms_modified
code_Fadd
fadd_dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
(* And here's the fadd wrapper itself *)
let lowstar_fadd : lowstar_fadd_t =
assert_norm (List.length fadd_dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
fadd_regs_modified
fadd_xmms_modified
code_Fadd
fadd_dom
(W.mk_prediction code_Fadd fadd_dom [] (fadd_lemma code_Fadd IA.win))
let lowstar_fadd_normal_t : normal lowstar_fadd_t
= as_normal_t #lowstar_fadd_t lowstar_fadd
let fadd out f1 f2
= DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
DV.length_eq (get_downview f2);
let (x, _) = lowstar_fadd_normal_t out f1 f2 () in
()
let fadd_comments : list string = ["Computes the field addition of two field elements"]
let fadd_names (n:nat) =
match n with
| 0 -> "out"
| 1 -> "f1"
| 2 -> "f2"
| _ -> ""
let fadd_code_inline () : FStar.All.ML int =
PR.print_inline "fadd" 0 None (List.length fadd_dom) fadd_dom fadd_names code_Fadd of_arg fadd_regs_modified fadd_comments
[@__reduce__]
let fsub_dom: IX64.arity_ok_stdcall td =
let y = [t64_mod; t64_no_mod; t64_no_mod] in
assert_norm (List.length y = 3);
y
(* Need to rearrange the order of arguments *)
[@__reduce__]
let fsub_pre : VSig.vale_pre fsub_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state) ->
FH.va_req_Fsub c va_s0
(as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2)
[@__reduce__]
let fsub_post : VSig.vale_post fsub_dom =
fun (c:V.va_code)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state)
(va_s1:V.va_state)
(f:V.va_fuel) ->
FH.va_ens_Fsub c va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) va_s1 f
#set-options "--z3rlimit 200"
let fsub_regs_modified: MS.reg_64 -> bool = fun (r:MS.reg_64) ->
let open MS in
if r = rRax || r = rRcx || r = rR8 || r = rR9 || r = rR10 || r = rR11 then true
else false
let fsub_xmms_modified = fun _ -> false
[@__reduce__]
let fsub_lemma'
(code:V.va_code)
(_win:bool)
(out:b64)
(f1:b64)
(f2:b64)
(va_s0:V.va_state)
: Ghost (V.va_state & V.va_fuel)
(requires
fsub_pre code out f1 f2 va_s0)
(ensures (fun (va_s1, f) ->
V.eval_code code va_s0 f va_s1 /\
VSig.vale_calling_conventions va_s0 va_s1 fsub_regs_modified fsub_xmms_modified /\
fsub_post code out f1 f2 va_s0 va_s1 f /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer out) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f1) /\
ME.buffer_readable (VS.vs_get_vale_heap va_s1) (as_vale_buffer f2) /\
ME.buffer_writeable (as_vale_buffer out) /\
ME.buffer_writeable (as_vale_buffer f1) /\
ME.buffer_writeable (as_vale_buffer f2) /\
ME.modifies (ME.loc_union (ME.loc_buffer (as_vale_buffer out))
ME.loc_none) (VS.vs_get_vale_heap va_s0) (VS.vs_get_vale_heap va_s1)
)) =
let va_s1, f = FH.va_lemma_Fsub code va_s0 (as_vale_buffer out) (as_vale_buffer f1) (as_vale_buffer f2) in
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 out;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f1;
Vale.AsLowStar.MemoryHelpers.buffer_writeable_reveal ME.TUInt64 ME.TUInt64 f2;
(va_s1, f)
(* Prove that fsub_lemma' has the required type *)
let fsub_lemma = as_t #(VSig.vale_sig fsub_regs_modified fsub_xmms_modified fsub_pre fsub_post) fsub_lemma'
let code_Fsub = FH.va_code_Fsub ()
(* Here's the type expected for the fsub wrapper *)
[@__reduce__]
let lowstar_Fsub_t =
assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3);
IX64.as_lowstar_sig_t_weak
3
arg_reg
fsub_regs_modified
fsub_xmms_modified
code_Fsub
fsub_dom
[]
_
_
// The boolean here doesn't matter
(W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win))
(* And here's the fsub wrapper itself *)
let lowstar_Fsub : lowstar_Fsub_t =
assert_norm (List.length fsub_dom + List.length ([]<:list arg) <= 3);
IX64.wrap_weak
3
arg_reg
fsub_regs_modified
fsub_xmms_modified
code_Fsub
fsub_dom
(W.mk_prediction code_Fsub fsub_dom [] (fsub_lemma code_Fsub IA.win))
let lowstar_Fsub_normal_t : normal lowstar_Fsub_t
= as_normal_t #lowstar_Fsub_t lowstar_Fsub | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Print_Inline_s.fst.checked",
"Vale.X64.MemoryAdapters.fsti.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.Interop.X64.fsti.checked",
"Vale.Interop.Base.fst.checked",
"Vale.Interop.Assumptions.fst.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Curve25519.X64.FastWide.fsti.checked",
"Vale.Curve25519.X64.FastUtil.fsti.checked",
"Vale.Curve25519.X64.FastHybrid.fsti.checked",
"Vale.AsLowStar.Wrapper.fsti.checked",
"Vale.AsLowStar.ValeSig.fst.checked",
"Vale.AsLowStar.MemoryHelpers.fsti.checked",
"Vale.AsLowStar.LowStarSig.fst.checked",
"prims.fst.checked",
"LowStar.BufferView.Down.fsti.checked",
"LowStar.Buffer.fst.checked",
"FStar.UInt64.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.List.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked",
"FStar.All.fst.checked"
],
"interface_file": true,
"source_file": "Vale.Inline.X64.Fadd_inline.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.AsLowStar.MemoryHelpers",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastWide",
"short_module": "FW"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastHybrid",
"short_module": "FH"
},
{
"abbrev": true,
"full_module": "Vale.Curve25519.X64.FastUtil",
"short_module": "FU"
},
{
"abbrev": true,
"full_module": "Vale.X64.Print_Inline_s",
"short_module": "PR"
},
{
"abbrev": true,
"full_module": "Vale.X64.Machine_s",
"short_module": "MS"
},
{
"abbrev": true,
"full_module": "Vale.X64.State",
"short_module": "VS"
},
{
"abbrev": false,
"full_module": "Vale.X64.MemoryAdapters",
"short_module": null
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.Wrapper",
"short_module": "W"
},
{
"abbrev": true,
"full_module": "Vale.Interop.Assumptions",
"short_module": "IA"
},
{
"abbrev": true,
"full_module": "Vale.X64.Decls",
"short_module": "V"
},
{
"abbrev": true,
"full_module": "Vale.X64.Memory",
"short_module": "ME"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.LowStarSig",
"short_module": "LSig"
},
{
"abbrev": true,
"full_module": "Vale.AsLowStar.ValeSig",
"short_module": "VSig"
},
{
"abbrev": true,
"full_module": "Vale.Interop.X64",
"short_module": "IX64"
},
{
"abbrev": false,
"full_module": "Vale.Interop.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Types_s",
"short_module": null
},
{
"abbrev": true,
"full_module": "LowStar.BufferView.Down",
"short_module": "DV"
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Curve25519.Fast_defs",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack",
"short_module": "HS"
},
{
"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.Inline.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Inline.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": 200,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
out: Vale.Inline.X64.Fadd_inline.u256 ->
f1: Vale.Inline.X64.Fadd_inline.u256 ->
f2: Vale.Inline.X64.Fadd_inline.u256
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Vale.Inline.X64.Fadd_inline.u256",
"FStar.UInt64.t",
"FStar.Ghost.erased",
"Vale.Interop.X64.as_lowstar_sig_ret",
"Prims.unit",
"Vale.Interop.X64.als_ret",
"Vale.Inline.X64.Fadd_inline.lowstar_Fsub_normal_t",
"LowStar.BufferView.Down.length_eq",
"FStar.UInt8.t",
"Vale.Interop.Types.get_downview",
"Vale.Arch.HeapTypes_s.TUInt64",
"LowStar.Buffer.trivial_preorder"
] | [] | false | true | false | false | false | let fsub out f1 f2 =
| DV.length_eq (get_downview out);
DV.length_eq (get_downview f1);
DV.length_eq (get_downview f2);
let x, _ = lowstar_Fsub_normal_t out f1 f2 () in
() | false |
AlgHeap.fst | AlgHeap.interp_rdwr_tree | val interp_rdwr_tree (#a: _) (t: tree a [Read; Write]) (s: state) : Tot (a & state) | val interp_rdwr_tree (#a: _) (t: tree a [Read; Write]) (s: state) : Tot (a & state) | let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 29,
"end_line": 252,
"start_col": 0,
"start_line": 246
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | t: AlgHeap.tree a [AlgHeap.Read; AlgHeap.Write] -> s: AlgHeap.state -> a * AlgHeap.state | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.tree",
"Prims.Cons",
"AlgHeap.op",
"AlgHeap.Read",
"AlgHeap.Write",
"Prims.Nil",
"AlgHeap.state",
"FStar.Pervasives.Native.Mktuple2",
"AlgHeap.op_inp",
"AlgHeap.op_out",
"AlgHeap.tree0",
"AlgHeap.interp_rdwr_tree",
"FStar.Pervasives.Native.tuple2"
] | [
"recursion"
] | false | false | false | true | false | let rec interp_rdwr_tree #a (t: tree a [Read; Write]) (s: state) : Tot (a & state) =
| match t with
| Return x -> (x, s)
| Op Read _ k -> interp_rdwr_tree (k s) s
| Op Write s k -> interp_rdwr_tree (k ()) s | false |
AlgHeap.fst | AlgHeap.bind2 | val bind2
(a b: Type)
(wp_v: st_wp a)
(wp_f: (a -> st_wp b))
(v: repr a wp_v)
(f: (x: a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) | val bind2
(a b: Type)
(wp_v: st_wp a)
(wp_f: (a -> st_wp b))
(v: repr a wp_v)
(f: (x: a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) | let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 11,
"end_line": 352,
"start_col": 0,
"start_line": 347
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 ->
wp_v: AlgHeap.st_wp a ->
wp_f: (_: a -> AlgHeap.st_wp b) ->
v: AlgHeap.repr a wp_v ->
f: (x: a -> AlgHeap.repr b (wp_f x))
-> AlgHeap.repr b (AlgHeap.bind_wp wp_v wp_f) | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.st_wp",
"AlgHeap.repr",
"AlgHeap.tbind",
"Prims.unit",
"AlgHeap.interp_bind",
"AlgHeap.bind_wp"
] | [] | false | false | false | false | false | let bind2
(a b: Type)
(wp_v: st_wp a)
(wp_f: (a -> st_wp b))
(v: repr a wp_v)
(f: (x: a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
| interp_bind v f wp_v wp_f;
tbind v f | false |
AlgHeap.fst | AlgHeap.lift_pure_wp | val lift_pure_wp (#a: Type) (wp: pure_wp a) : st_wp a | val lift_pure_wp (#a: Type) (wp: pure_wp a) : st_wp a | let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0)) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 37,
"end_line": 388,
"start_col": 0,
"start_line": 386
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | wp: Prims.pure_wp a -> AlgHeap.st_wp a | Prims.Tot | [
"total"
] | [] | [
"Prims.pure_wp",
"AlgHeap.state",
"FStar.Pervasives.Native.tuple2",
"Prims.l_True",
"FStar.Pervasives.Native.Mktuple2",
"Prims.pure_pre",
"Prims.unit",
"FStar.Monotonic.Pure.elim_pure_wp_monotonicity",
"AlgHeap.st_wp"
] | [] | false | false | false | true | false | let lift_pure_wp (#a: Type) (wp: pure_wp a) : st_wp a =
| elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0)) | false |
AlgHeap.fst | AlgHeap.lift_pure_algwp | val lift_pure_algwp (a: Type) (wp: _) (f: (unit -> PURE a wp))
: Pure (repr a (lift_pure_wp wp)) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) | val lift_pure_algwp (a: Type) (wp: _) (f: (unit -> PURE a wp))
: Pure (repr a (lift_pure_wp wp)) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) | let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 12,
"end_line": 398,
"start_col": 0,
"start_line": 390
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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: Prims.pure_wp a -> f: (_: Prims.unit -> Prims.PURE a)
-> Prims.Pure (AlgHeap.repr a (AlgHeap.lift_pure_wp wp)) | Prims.Pure | [] | [] | [
"Prims.pure_wp",
"Prims.unit",
"AlgHeap.Return",
"FStar.Pervasives.assert_norm",
"AlgHeap.stronger",
"AlgHeap.lift_pure_wp",
"AlgHeap.return_wp",
"Prims._assert",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.Monotonic.Pure.elim_pure_wp_monotonicity",
"FStar.Monotonic.Pure.elim_pure",
"Prims.l_True",
"AlgHeap.repr"
] | [] | false | false | false | false | false | let lift_pure_algwp (a: Type) wp (f: (unit -> PURE a wp))
: Pure (repr a (lift_pure_wp wp)) (requires (wp (fun _ -> True))) (ensures (fun _ -> True)) =
| let v:a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
assert (forall p. wp p ==> p v);
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v | false |
AlgHeap.fst | AlgHeap.interp_monotonic | val interp_monotonic (#a: _) (c: rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) | val interp_monotonic (#a: _) (c: rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) | let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x)) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 65,
"end_line": 291,
"start_col": 0,
"start_line": 277
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | c: AlgHeap.rwtree a
-> FStar.Pervasives.Lemma (ensures AlgHeap.wp_is_monotonic (AlgHeap.interp_as_wp c)) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"AlgHeap.rwtree",
"AlgHeap.op_inp",
"AlgHeap.Read",
"AlgHeap.op_out",
"AlgHeap.tree0",
"AlgHeap.bind_preserves_mon",
"AlgHeap.state",
"AlgHeap.read_wp",
"AlgHeap.interp_as_wp",
"AlgHeap.st_wp",
"Prims.unit",
"FStar.Classical.forall_intro",
"AlgHeap.wp_is_monotonic",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"AlgHeap.interp_monotonic",
"AlgHeap.Write",
"AlgHeap.write_wp"
] | [
"recursion"
] | false | false | true | false | false | let rec interp_monotonic #a (c: rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
| match c with
| Return x -> ()
| Op Read _ k ->
let aux (x: state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) = interp_monotonic (k x) in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x: unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) = interp_monotonic (k x) in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x)) | false |
AlgHeap.fst | AlgHeap.interp_bind | val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f)) | val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f)) | let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 30,
"end_line": 338,
"start_col": 0,
"start_line": 324
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 |
c: AlgHeap.rwtree a ->
f: (_: a -> AlgHeap.rwtree b) ->
w1: AlgHeap.st_wp a ->
w2: (_: a -> AlgHeap.st_wp b)
-> FStar.Pervasives.Lemma
(requires
w1 <<= AlgHeap.interp_as_wp c /\ (forall (x: a). w2 x <<= AlgHeap.interp_as_wp (f x)))
(ensures AlgHeap.stronger (AlgHeap.bind_wp w1 w2) (AlgHeap.interp_as_wp (AlgHeap.tbind c f))) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"AlgHeap.rwtree",
"AlgHeap.st_wp",
"FStar.Classical.forall_intro_2",
"FStar.Pervasives.Native.tuple2",
"AlgHeap.state",
"Prims.l_imp",
"AlgHeap.bind_wp",
"AlgHeap.interp_as_wp",
"AlgHeap.tbind",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"FStar.Calc.calc_finish",
"Prims.logical",
"Prims.Cons",
"FStar.Preorder.relation",
"FStar.Calc.calc_step",
"FStar.Calc.calc_init",
"FStar.Calc.calc_pack",
"FStar.Calc.calc_push_impl",
"AlgHeap.interp_monotonic",
"AlgHeap.interp_morph"
] | [] | false | false | true | false | false | let interp_bind #a #b c f w1 w2 =
| let aux (p: ((b & state) -> Type0)) (s0: state)
: Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc ( ==> ) {
bind_wp w1 w2 s0 p;
( ==> ) { () }
w1 s0 (fun (y, s1) -> w2 y s1 p);
( ==> ) { () }
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
( ==> ) { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
( ==> ) { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux | false |
AlgHeap.fst | AlgHeap.put2 | val put2 (s: state) : AlgWP unit (write_wp s) | val put2 (s: state) : AlgWP unit (write_wp s) | let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 25,
"end_line": 381,
"start_col": 0,
"start_line": 380
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | s: AlgHeap.state -> AlgHeap.AlgWP Prims.unit | AlgHeap.AlgWP | [] | [] | [
"AlgHeap.state",
"AlgHeap._put",
"Prims.unit",
"AlgHeap.write_wp"
] | [] | false | true | false | false | false | let put2 (s: state) : AlgWP unit (write_wp s) =
| AlgWP?.reflect (_put s) | false |
AlgHeap.fst | AlgHeap.return2 | val return2 (a: Type) (x: a) : repr a (return_wp x) | val return2 (a: Type) (x: a) : repr a (return_wp x) | let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 10,
"end_line": 345,
"start_col": 0,
"start_line": 343
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 -> AlgHeap.repr a (AlgHeap.return_wp x) | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.Return",
"Prims.unit",
"AlgHeap.interp_ret",
"AlgHeap.repr",
"AlgHeap.return_wp"
] | [] | false | false | false | false | false | let return2 (a: Type) (x: a) : repr a (return_wp x) =
| interp_ret x;
Return x | false |
AlgHeap.fst | AlgHeap.upd | val upd (r: loc) (v: int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) | val upd (r: loc) (v: int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) | let upd (r:loc) (v:int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
let h = get2 () in
put2 (Map.upd h r v) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 22,
"end_line": 408,
"start_col": 0,
"start_line": 406
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp
let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | r: AlgHeap.loc -> v: Prims.int -> AlgHeap.AlgWP Prims.unit | AlgHeap.AlgWP | [] | [] | [
"AlgHeap.loc",
"Prims.int",
"AlgHeap.put2",
"FStar.Map.upd",
"Prims.unit",
"AlgHeap.state",
"AlgHeap.get2",
"FStar.Map.t",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2"
] | [] | false | true | false | false | false | let upd (r: loc) (v: int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
| let h = get2 () in
put2 (Map.upd h r v) | false |
AlgHeap.fst | AlgHeap.subcomp2 | val subcomp2 (a: Type) (w1 w2: st_wp a) (f: repr a w1)
: Pure (repr a w2) (requires w2 `stronger` w1) (ensures fun _ -> True) | val subcomp2 (a: Type) (w1 w2: st_wp a) (f: repr a w1)
: Pure (repr a w2) (requires w2 `stronger` w1) (ensures fun _ -> True) | let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 5,
"end_line": 359,
"start_col": 0,
"start_line": 354
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 -> w1: AlgHeap.st_wp a -> w2: AlgHeap.st_wp a -> f: AlgHeap.repr a w1
-> Prims.Pure (AlgHeap.repr a w2) | Prims.Pure | [] | [] | [
"AlgHeap.st_wp",
"AlgHeap.repr",
"AlgHeap.stronger",
"Prims.l_True"
] | [] | false | false | false | false | false | let subcomp2 (a: Type) (w1 w2: st_wp a) (f: repr a w1)
: Pure (repr a w2) (requires w2 `stronger` w1) (ensures fun _ -> True) =
| f | false |
AlgHeap.fst | AlgHeap.swap | val swap (l1 l2: loc)
: AlgPP unit
(fun _ -> l1 <> l2)
(fun h0 _ h1 ->
modifies [l1; l2] h0 h1 /\ Map.sel h1 l1 == Map.sel h0 l2 /\
Map.sel h1 l2 == Map.sel h0 l1) | val swap (l1 l2: loc)
: AlgPP unit
(fun _ -> l1 <> l2)
(fun h0 _ h1 ->
modifies [l1; l2] h0 h1 /\ Map.sel h1 l1 == Map.sel h0 l2 /\
Map.sel h1 l2 == Map.sel h0 l1) | let swap (l1 l2 : loc) : AlgPP unit (fun _ -> l1 <> l2)
(fun h0 _ h1 ->
modifies [l1;l2] h0 h1 /\
Map.sel h1 l1 == Map.sel h0 l2 /\
Map.sel h1 l2 == Map.sel h0 l1)
=
let r = !l2 in
l2 := !l1;
l1 := r | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 9,
"end_line": 434,
"start_col": 0,
"start_line": 426
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp
let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r
let upd (r:loc) (v:int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
let h = get2 () in
put2 (Map.upd h r v)
let (!) = sel
let (:=) = upd
let modifies1 (l:loc) (h0 h1 : state) : Type0 =
forall y. y <> l ==> Map.sel h0 y == Map.sel h1 y
let modifies (ls: list loc) (h0 h1 : state) : Type0 =
forall y. mem y ls \/ (Map.sel h0 y == Map.sel h1 y)
effect AlgPP (a:Type) (pre : state -> Type0) (post : state -> a -> state -> Type0) =
AlgWP a (fun h0 p -> pre h0 /\ (forall y h1. post h0 y h1 ==> p (y, h1)))
let addx (l:loc) (x:int) : AlgPP unit (fun _ -> True) (fun h0 _ h1 -> modifies1 l h0 h1
/\ (Map.sel h1 l == x + Map.sel h0 l)) =
l := !l + x | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | l1: AlgHeap.loc -> l2: AlgHeap.loc -> AlgHeap.AlgPP Prims.unit | AlgHeap.AlgPP | [] | [] | [
"AlgHeap.loc",
"AlgHeap.op_Colon_Equals",
"Prims.unit",
"Prims.int",
"AlgHeap.op_Bang",
"AlgHeap.state",
"Prims.b2t",
"Prims.op_disEquality",
"Prims.l_and",
"AlgHeap.modifies",
"Prims.Cons",
"Prims.Nil",
"Prims.eq2",
"FStar.Map.sel"
] | [] | false | true | false | false | false | let swap (l1 l2: loc)
: AlgPP unit
(fun _ -> l1 <> l2)
(fun h0 _ h1 ->
modifies [l1; l2] h0 h1 /\ Map.sel h1 l1 == Map.sel h0 l2 /\
Map.sel h1 l2 == Map.sel h0 l1) =
| let r = !l2 in
l2 := !l1;
l1 := r | false |
Hacl.Bignum.ModInv.fst | Hacl.Bignum.ModInv.mk_bn_mod_inv_prime | val mk_bn_mod_inv_prime:
#t:limb_t
-> len:BN.meta_len t
-> bn_mod_exp:BE.bn_mod_exp_st t len ->
bn_mod_inv_prime_st t len | val mk_bn_mod_inv_prime:
#t:limb_t
-> len:BN.meta_len t
-> bn_mod_exp:BE.bn_mod_exp_st t len ->
bn_mod_inv_prime_st t len | let mk_bn_mod_inv_prime #t len bn_mod_exp nBits n a res =
let h0 = ST.get () in
push_frame ();
let n2 = create len (uint #t #SEC 0) in
bn_mod_inv_prime_n2 #t len n n2;
SD.bn_eval_bound (as_seq h0 n) (v len);
bn_mod_exp nBits n a (size (bits t) *! len) n2 res;
let h1 = ST.get () in
assert (bn_v h1 res == Lib.NatMod.pow_mod #(bn_v h0 n) (bn_v h0 a) (bn_v h1 n2));
S.mod_inv_prime_lemma (bn_v h0 n) (bn_v h0 a);
pop_frame () | {
"file_name": "code/bignum/Hacl.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 135,
"start_col": 0,
"start_line": 124
} | module Hacl.Bignum.ModInv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModInv
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module SD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a))
inline_for_extraction noextract
val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len
let bn_check_mod_inv_prime #t len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask len a in
let m2 = BN.bn_lt_mask len a n in
m0 &. (lognot m1) &. m2
inline_for_extraction noextract
val bn_mod_inv_prime_n2:
#t:limb_t
-> len:BN.meta_len t
-> n:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h -> 1 < bn_v h n /\
live h n /\ live h res /\ disjoint res n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mod_inv_prime_n2 (as_seq h0 n))
let bn_mod_inv_prime_n2 #t len n res =
let c = BN.bn_sub1 len n (uint #t #SEC 2) res in
LowStar.Ignore.ignore c;
()
inline_for_extraction noextract
let bn_mod_inv_prime_precomp_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h r2 /\ live h a /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint n a /\
disjoint res r2 /\ disjoint a r2 /\ disjoint n r2 /\
S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a) /\
bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n /\
(1 + bn_v h n * v mu) % pow2 (bits t) == 0)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res * bn_v h0 a % bn_v h0 n = 1)
inline_for_extraction noextract
val mk_bn_mod_inv_prime_precomp:
#t:limb_t
-> len:BN.meta_len t
-> bn_mod_exp_precomp:BE.bn_mod_exp_precomp_st t len ->
bn_mod_inv_prime_precomp_st t len
let mk_bn_mod_inv_prime_precomp #t len bn_mod_exp_precomp n mu r2 a res =
let h0 = ST.get () in
push_frame ();
let n2 = create len (uint #t #SEC 0) in
bn_mod_inv_prime_n2 #t len n n2;
SD.bn_eval_bound (as_seq h0 n) (v len);
bn_mod_exp_precomp n mu r2 a (size (bits t) *! len) n2 res;
let h1 = ST.get () in
assert (bn_v h1 res == Lib.NatMod.pow_mod #(bn_v h0 n) (bn_v h0 a) (bn_v h1 n2));
S.mod_inv_prime_lemma (bn_v h0 n) (bn_v h0 a);
pop_frame ()
inline_for_extraction noextract
let bn_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) =
nBits:size_t
-> n:lbignum t len
-> a:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h a /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint n a /\
v nBits / bits t < v len /\ pow2 (v nBits) < bn_v h n /\
S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a))
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res * bn_v h0 a % bn_v h0 n = 1)
inline_for_extraction noextract
val mk_bn_mod_inv_prime:
#t:limb_t
-> len:BN.meta_len t
-> bn_mod_exp:BE.bn_mod_exp_st t len ->
bn_mod_inv_prime_st t len | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.ModInv.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModInv",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | len: Hacl.Bignum.meta_len t -> bn_mod_exp: Hacl.Bignum.Exponentiation.bn_mod_exp_st t len
-> Hacl.Bignum.ModInv.bn_mod_inv_prime_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Exponentiation.bn_mod_exp_st",
"Lib.IntTypes.size_t",
"Hacl.Bignum.Definitions.lbignum",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.Bignum.ModInv.mod_inv_prime_lemma",
"Hacl.Bignum.Definitions.bn_v",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Lib.NatMod.pow_mod",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Lib.IntTypes.v",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Hacl.Bignum.ModInv.bn_mod_inv_prime_n2",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let mk_bn_mod_inv_prime #t len bn_mod_exp nBits n a res =
| let h0 = ST.get () in
push_frame ();
let n2 = create len (uint #t #SEC 0) in
bn_mod_inv_prime_n2 #t len n n2;
SD.bn_eval_bound (as_seq h0 n) (v len);
bn_mod_exp nBits n a (size (bits t) *! len) n2 res;
let h1 = ST.get () in
assert (bn_v h1 res == Lib.NatMod.pow_mod #(bn_v h0 n) (bn_v h0 a) (bn_v h1 n2));
S.mod_inv_prime_lemma (bn_v h0 n) (bn_v h0 a);
pop_frame () | false |
AlgHeap.fst | AlgHeap.get2 | val get2: Prims.unit -> AlgWP state read_wp | val get2: Prims.unit -> AlgWP state read_wp | let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 21,
"end_line": 378,
"start_col": 0,
"start_line": 377
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
} | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 -> AlgHeap.AlgWP AlgHeap.state | AlgHeap.AlgWP | [] | [] | [
"Prims.unit",
"AlgHeap._get",
"AlgHeap.state",
"AlgHeap.read_wp"
] | [] | false | true | false | false | false | let get2 () : AlgWP state read_wp =
| AlgWP?.reflect _get | false |
AlgHeap.fst | AlgHeap.addx | val addx (l: loc) (x: int)
: AlgPP unit
(fun _ -> True)
(fun h0 _ h1 -> modifies1 l h0 h1 /\ (Map.sel h1 l == x + Map.sel h0 l)) | val addx (l: loc) (x: int)
: AlgPP unit
(fun _ -> True)
(fun h0 _ h1 -> modifies1 l h0 h1 /\ (Map.sel h1 l == x + Map.sel h0 l)) | let addx (l:loc) (x:int) : AlgPP unit (fun _ -> True) (fun h0 _ h1 -> modifies1 l h0 h1
/\ (Map.sel h1 l == x + Map.sel h0 l)) =
l := !l + x | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 424,
"start_col": 0,
"start_line": 422
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp
let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r
let upd (r:loc) (v:int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
let h = get2 () in
put2 (Map.upd h r v)
let (!) = sel
let (:=) = upd
let modifies1 (l:loc) (h0 h1 : state) : Type0 =
forall y. y <> l ==> Map.sel h0 y == Map.sel h1 y
let modifies (ls: list loc) (h0 h1 : state) : Type0 =
forall y. mem y ls \/ (Map.sel h0 y == Map.sel h1 y)
effect AlgPP (a:Type) (pre : state -> Type0) (post : state -> a -> state -> Type0) =
AlgWP a (fun h0 p -> pre h0 /\ (forall y h1. post h0 y h1 ==> p (y, h1))) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | l: AlgHeap.loc -> x: Prims.int -> AlgHeap.AlgPP Prims.unit | AlgHeap.AlgPP | [] | [] | [
"AlgHeap.loc",
"Prims.int",
"AlgHeap.op_Colon_Equals",
"Prims.unit",
"Prims.op_Addition",
"AlgHeap.op_Bang",
"AlgHeap.state",
"Prims.l_True",
"Prims.l_and",
"AlgHeap.modifies1",
"Prims.eq2",
"FStar.Map.sel"
] | [] | false | true | false | false | false | let addx (l: loc) (x: int)
: AlgPP unit
(fun _ -> True)
(fun h0 _ h1 -> modifies1 l h0 h1 /\ (Map.sel h1 l == x + Map.sel h0 l)) =
| l := !l + x | false |
AlgHeap.fst | AlgHeap.sel | val sel (r: loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) | val sel (r: loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) | let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 404,
"start_col": 0,
"start_line": 402
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | r: AlgHeap.loc -> AlgHeap.AlgWP Prims.int | AlgHeap.AlgWP | [] | [] | [
"AlgHeap.loc",
"FStar.Map.sel",
"Prims.int",
"AlgHeap.state",
"AlgHeap.get2",
"FStar.Map.t",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2"
] | [] | false | true | false | false | false | let sel (r: loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
| let h = get2 () in
Map.sel h r | false |
AlgHeap.fst | AlgHeap.soundnessPP | val soundnessPP (#a #pre #post: _) (t: (unit -> AlgPP a pre post)) (s0: state{pre s0})
: r: (a & state){post s0 (fst r) (snd r)} | val soundnessPP (#a #pre #post: _) (t: (unit -> AlgPP a pre post)) (s0: state{pre s0})
: r: (a & state){post s0 (fst r) (snd r)} | let soundnessPP #a #pre #post (t : unit -> AlgPP a pre post)
: s0:state{pre s0} -> r:(a & state){post s0 (fst r) (snd r)}
= fun s0 -> reify (soundness #a #(fun h0 p -> pre h0 /\ (forall y h1. post h0 y h1 ==> p (y, h1))) t s0)
(fun r -> post s0 (fst r) (snd r))
() | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 19,
"end_line": 464,
"start_col": 0,
"start_line": 460
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp
let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r
let upd (r:loc) (v:int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
let h = get2 () in
put2 (Map.upd h r v)
let (!) = sel
let (:=) = upd
let modifies1 (l:loc) (h0 h1 : state) : Type0 =
forall y. y <> l ==> Map.sel h0 y == Map.sel h1 y
let modifies (ls: list loc) (h0 h1 : state) : Type0 =
forall y. mem y ls \/ (Map.sel h0 y == Map.sel h1 y)
effect AlgPP (a:Type) (pre : state -> Type0) (post : state -> a -> state -> Type0) =
AlgWP a (fun h0 p -> pre h0 /\ (forall y h1. post h0 y h1 ==> p (y, h1)))
let addx (l:loc) (x:int) : AlgPP unit (fun _ -> True) (fun h0 _ h1 -> modifies1 l h0 h1
/\ (Map.sel h1 l == x + Map.sel h0 l)) =
l := !l + x
let swap (l1 l2 : loc) : AlgPP unit (fun _ -> l1 <> l2)
(fun h0 _ h1 ->
modifies [l1;l2] h0 h1 /\
Map.sel h1 l1 == Map.sel h0 l2 /\
Map.sel h1 l2 == Map.sel h0 l1)
=
let r = !l2 in
l2 := !l1;
l1 := r
let rec interp_sem #a (t : rwtree a) (s0:state)
: ID5.ID (a & state) (as_pure_wp (interp_as_wp t s0))
= match t with
| Return x -> (x, s0)
| Op Read i k ->
interp_sem (k s0) s0
| Op Write i k ->
interp_sem (k ()) i
let extract #a #w (c:repr a w)
: Lemma (w `stronger` interp_as_wp c)
= ()
let soundness_aux #a #wp (t:repr a wp)
: Tot (s0:state -> ID5.ID (a & state) (as_pure_wp (wp s0)))
= extract t;
interp_sem t
let soundness #a #wp (t : unit -> AlgWP a wp)
: Tot (s0:state -> ID5.ID (a & state) (as_pure_wp (wp s0)))
= soundness_aux (reify (t ())) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | t: (_: Prims.unit -> AlgHeap.AlgPP a) -> s0: AlgHeap.state{pre s0}
-> r:
(a * AlgHeap.state) {post s0 (FStar.Pervasives.Native.fst r) (FStar.Pervasives.Native.snd r)} | Prims.Tot | [
"total"
] | [] | [
"AlgHeap.state",
"Prims.unit",
"AlgHeap.soundness",
"FStar.Pervasives.Native.tuple2",
"Prims.logical",
"Prims.l_and",
"Prims.l_Forall",
"Prims.l_imp",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Ghost.hide",
"FStar.Pervasives.Native.fst",
"FStar.Pervasives.Native.snd"
] | [] | false | false | false | false | false | let soundnessPP #a #pre #post (t: (unit -> AlgPP a pre post))
(s0: state{pre s0}) : r: (a & state){post s0 (fst r) (snd r)} =
| fun s0 ->
reify (soundness #a #(fun h0 p -> pre h0 /\ (forall y h1. post h0 y h1 ==> p (y, h1))) t s0)
(fun r -> post s0 (fst r) (snd r))
() | false |
Hacl.Bignum.ModInv.fst | Hacl.Bignum.ModInv.mk_bn_mod_inv_prime_precomp | val mk_bn_mod_inv_prime_precomp:
#t:limb_t
-> len:BN.meta_len t
-> bn_mod_exp_precomp:BE.bn_mod_exp_precomp_st t len ->
bn_mod_inv_prime_precomp_st t len | val mk_bn_mod_inv_prime_precomp:
#t:limb_t
-> len:BN.meta_len t
-> bn_mod_exp_precomp:BE.bn_mod_exp_precomp_st t len ->
bn_mod_inv_prime_precomp_st t len | let mk_bn_mod_inv_prime_precomp #t len bn_mod_exp_precomp n mu r2 a res =
let h0 = ST.get () in
push_frame ();
let n2 = create len (uint #t #SEC 0) in
bn_mod_inv_prime_n2 #t len n n2;
SD.bn_eval_bound (as_seq h0 n) (v len);
bn_mod_exp_precomp n mu r2 a (size (bits t) *! len) n2 res;
let h1 = ST.get () in
assert (bn_v h1 res == Lib.NatMod.pow_mod #(bn_v h0 n) (bn_v h0 a) (bn_v h1 n2));
S.mod_inv_prime_lemma (bn_v h0 n) (bn_v h0 a);
pop_frame () | {
"file_name": "code/bignum/Hacl.Bignum.ModInv.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 14,
"end_line": 97,
"start_col": 0,
"start_line": 86
} | module Hacl.Bignum.ModInv
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module S = Hacl.Spec.Bignum.ModInv
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module SD = Hacl.Spec.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let bn_check_mod_inv_prime_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> a:lbignum t len ->
Stack (limb t)
(requires fun h -> live h n /\ live h a /\ disjoint n a)
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == S.bn_check_mod_inv_prime (as_seq h0 n) (as_seq h0 a))
inline_for_extraction noextract
val bn_check_mod_inv_prime: #t:limb_t -> len:BN.meta_len t -> bn_check_mod_inv_prime_st t len
let bn_check_mod_inv_prime #t len n a =
let m0 = BM.bn_check_modulus n in
let m1 = BN.bn_is_zero_mask len a in
let m2 = BN.bn_lt_mask len a n in
m0 &. (lognot m1) &. m2
inline_for_extraction noextract
val bn_mod_inv_prime_n2:
#t:limb_t
-> len:BN.meta_len t
-> n:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h -> 1 < bn_v h n /\
live h n /\ live h res /\ disjoint res n)
(ensures fun h0 _ h1 -> modifies (loc res) h0 h1 /\
as_seq h1 res == S.bn_mod_inv_prime_n2 (as_seq h0 n))
let bn_mod_inv_prime_n2 #t len n res =
let c = BN.bn_sub1 len n (uint #t #SEC 2) res in
LowStar.Ignore.ignore c;
()
inline_for_extraction noextract
let bn_mod_inv_prime_precomp_st (t:limb_t) (len:BN.meta_len t) =
n:lbignum t len
-> mu:limb t
-> r2:lbignum t len
-> a:lbignum t len
-> res:lbignum t len ->
Stack unit
(requires fun h ->
live h n /\ live h r2 /\ live h a /\ live h res /\
disjoint res n /\ disjoint res a /\ disjoint n a /\
disjoint res r2 /\ disjoint a r2 /\ disjoint n r2 /\
S.bn_mod_inv_prime_pre (as_seq h n) (as_seq h a) /\
bn_v h r2 == pow2 (2 * bits t * v len) % bn_v h n /\
(1 + bn_v h n * v mu) % pow2 (bits t) == 0)
(ensures fun h0 r h1 -> modifies (loc res) h0 h1 /\
bn_v h1 res * bn_v h0 a % bn_v h0 n = 1)
inline_for_extraction noextract
val mk_bn_mod_inv_prime_precomp:
#t:limb_t
-> len:BN.meta_len t
-> bn_mod_exp_precomp:BE.bn_mod_exp_precomp_st t len ->
bn_mod_inv_prime_precomp_st t len | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Ignore.fsti.checked",
"Lib.NatMod.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.Bignum.ModInv.fst.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Bignum.ModInv.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.ModInv",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
len: Hacl.Bignum.meta_len t ->
bn_mod_exp_precomp: Hacl.Bignum.Exponentiation.bn_mod_exp_precomp_st t len
-> Hacl.Bignum.ModInv.bn_mod_inv_prime_precomp_st t len | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.meta_len",
"Hacl.Bignum.Exponentiation.bn_mod_exp_precomp_st",
"Hacl.Bignum.Definitions.lbignum",
"Hacl.Bignum.Definitions.limb",
"FStar.HyperStack.ST.pop_frame",
"Prims.unit",
"Hacl.Spec.Bignum.ModInv.mod_inv_prime_lemma",
"Hacl.Bignum.Definitions.bn_v",
"Prims._assert",
"Prims.eq2",
"Prims.nat",
"Lib.NatMod.pow_mod",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Hacl.Spec.Bignum.Definitions.bn_eval_bound",
"Lib.IntTypes.v",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Bignum.ModInv.bn_mod_inv_prime_n2",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.Buffer.lbuffer",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let mk_bn_mod_inv_prime_precomp #t len bn_mod_exp_precomp n mu r2 a res =
| let h0 = ST.get () in
push_frame ();
let n2 = create len (uint #t #SEC 0) in
bn_mod_inv_prime_n2 #t len n n2;
SD.bn_eval_bound (as_seq h0 n) (v len);
bn_mod_exp_precomp n mu r2 a (size (bits t) *! len) n2 res;
let h1 = ST.get () in
assert (bn_v h1 res == Lib.NatMod.pow_mod #(bn_v h0 n) (bn_v h0 a) (bn_v h1 n2));
S.mod_inv_prime_lemma (bn_v h0 n) (bn_v h0 a);
pop_frame () | false |
AlgHeap.fst | AlgHeap.soundness_aux | val soundness_aux (#a #wp: _) (t: repr a wp)
: Tot (s0: state -> ID5.ID (a & state) (as_pure_wp (wp s0))) | val soundness_aux (#a #wp: _) (t: repr a wp)
: Tot (s0: state -> ID5.ID (a & state) (as_pure_wp (wp s0))) | let soundness_aux #a #wp (t:repr a wp)
: Tot (s0:state -> ID5.ID (a & state) (as_pure_wp (wp s0)))
= extract t;
interp_sem t | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 16,
"end_line": 453,
"start_col": 0,
"start_line": 450
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp
let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r
let upd (r:loc) (v:int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
let h = get2 () in
put2 (Map.upd h r v)
let (!) = sel
let (:=) = upd
let modifies1 (l:loc) (h0 h1 : state) : Type0 =
forall y. y <> l ==> Map.sel h0 y == Map.sel h1 y
let modifies (ls: list loc) (h0 h1 : state) : Type0 =
forall y. mem y ls \/ (Map.sel h0 y == Map.sel h1 y)
effect AlgPP (a:Type) (pre : state -> Type0) (post : state -> a -> state -> Type0) =
AlgWP a (fun h0 p -> pre h0 /\ (forall y h1. post h0 y h1 ==> p (y, h1)))
let addx (l:loc) (x:int) : AlgPP unit (fun _ -> True) (fun h0 _ h1 -> modifies1 l h0 h1
/\ (Map.sel h1 l == x + Map.sel h0 l)) =
l := !l + x
let swap (l1 l2 : loc) : AlgPP unit (fun _ -> l1 <> l2)
(fun h0 _ h1 ->
modifies [l1;l2] h0 h1 /\
Map.sel h1 l1 == Map.sel h0 l2 /\
Map.sel h1 l2 == Map.sel h0 l1)
=
let r = !l2 in
l2 := !l1;
l1 := r
let rec interp_sem #a (t : rwtree a) (s0:state)
: ID5.ID (a & state) (as_pure_wp (interp_as_wp t s0))
= match t with
| Return x -> (x, s0)
| Op Read i k ->
interp_sem (k s0) s0
| Op Write i k ->
interp_sem (k ()) i
let extract #a #w (c:repr a w)
: Lemma (w `stronger` interp_as_wp c)
= () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | t: AlgHeap.repr a wp -> s0: AlgHeap.state -> ID5.ID (a * AlgHeap.state) | ID5.ID | [] | [] | [
"AlgHeap.st_wp",
"AlgHeap.repr",
"AlgHeap.interp_sem",
"Prims.unit",
"AlgHeap.extract",
"AlgHeap.state",
"FStar.Pervasives.Native.tuple2",
"FStar.Monotonic.Pure.as_pure_wp"
] | [] | false | true | false | false | false | let soundness_aux #a #wp (t: repr a wp) : Tot (s0: state -> ID5.ID (a & state) (as_pure_wp (wp s0))) =
| extract t;
interp_sem t | false |
AlgHeap.fst | AlgHeap.interp_morph | val interp_morph (#a #b: _) (c: rwtree a) (f: (a -> rwtree b)) (p s0: _)
: Lemma
(interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p) | val interp_morph (#a #b: _) (c: rwtree a) (f: (a -> rwtree b)) (p s0: _)
: Lemma
(interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p) | let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 13,
"end_line": 317,
"start_col": 0,
"start_line": 299
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= () | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 |
c: AlgHeap.rwtree a ->
f: (_: a -> AlgHeap.rwtree b) ->
p: (_: (b * AlgHeap.state) -> Type0) ->
s0: AlgHeap.state
-> FStar.Pervasives.Lemma
(ensures
AlgHeap.interp_as_wp c
s0
(fun _ ->
(let FStar.Pervasives.Native.Mktuple2 #_ #_ y s1 = _ in
AlgHeap.interp_as_wp (f y) s1 p)
<:
Type0) ==
AlgHeap.interp_as_wp (AlgHeap.tbind c f) s0 p) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"AlgHeap.rwtree",
"FStar.Pervasives.Native.tuple2",
"AlgHeap.state",
"AlgHeap.op_inp",
"AlgHeap.Read",
"AlgHeap.op_out",
"AlgHeap.tree0",
"FStar.Classical.forall_intro",
"Prims.eq2",
"AlgHeap.interp_as_wp",
"AlgHeap.tbind",
"Prims.unit",
"Prims.l_True",
"Prims.squash",
"Prims.Nil",
"FStar.Pervasives.pattern",
"AlgHeap.interp_morph",
"AlgHeap.Write"
] | [
"recursion"
] | false | false | true | false | false | let rec interp_morph #a #b (c: rwtree a) (f: (a -> rwtree b)) (p: _) (s0: _)
: Lemma
(interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p) =
| match c with
| Return x -> ()
| Op Read _ k ->
let aux (o: state)
: Lemma
(interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) ==
interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o: unit)
: Lemma
(interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p) ==
interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () | false |
AlgHeap.fst | AlgHeap.soundness | val soundness (#a #wp: _) (t: (unit -> AlgWP a wp))
: Tot (s0: state -> ID5.ID (a & state) (as_pure_wp (wp s0))) | val soundness (#a #wp: _) (t: (unit -> AlgWP a wp))
: Tot (s0: state -> ID5.ID (a & state) (as_pure_wp (wp s0))) | let soundness #a #wp (t : unit -> AlgWP a wp)
: Tot (s0:state -> ID5.ID (a & state) (as_pure_wp (wp s0)))
= soundness_aux (reify (t ())) | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 32,
"end_line": 457,
"start_col": 0,
"start_line": 455
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp
let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r
let upd (r:loc) (v:int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
let h = get2 () in
put2 (Map.upd h r v)
let (!) = sel
let (:=) = upd
let modifies1 (l:loc) (h0 h1 : state) : Type0 =
forall y. y <> l ==> Map.sel h0 y == Map.sel h1 y
let modifies (ls: list loc) (h0 h1 : state) : Type0 =
forall y. mem y ls \/ (Map.sel h0 y == Map.sel h1 y)
effect AlgPP (a:Type) (pre : state -> Type0) (post : state -> a -> state -> Type0) =
AlgWP a (fun h0 p -> pre h0 /\ (forall y h1. post h0 y h1 ==> p (y, h1)))
let addx (l:loc) (x:int) : AlgPP unit (fun _ -> True) (fun h0 _ h1 -> modifies1 l h0 h1
/\ (Map.sel h1 l == x + Map.sel h0 l)) =
l := !l + x
let swap (l1 l2 : loc) : AlgPP unit (fun _ -> l1 <> l2)
(fun h0 _ h1 ->
modifies [l1;l2] h0 h1 /\
Map.sel h1 l1 == Map.sel h0 l2 /\
Map.sel h1 l2 == Map.sel h0 l1)
=
let r = !l2 in
l2 := !l1;
l1 := r
let rec interp_sem #a (t : rwtree a) (s0:state)
: ID5.ID (a & state) (as_pure_wp (interp_as_wp t s0))
= match t with
| Return x -> (x, s0)
| Op Read i k ->
interp_sem (k s0) s0
| Op Write i k ->
interp_sem (k ()) i
let extract #a #w (c:repr a w)
: Lemma (w `stronger` interp_as_wp c)
= ()
let soundness_aux #a #wp (t:repr a wp)
: Tot (s0:state -> ID5.ID (a & state) (as_pure_wp (wp s0)))
= extract t;
interp_sem t | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | t: (_: Prims.unit -> AlgHeap.AlgWP a) -> s0: AlgHeap.state -> ID5.ID (a * AlgHeap.state) | ID5.ID | [] | [] | [
"AlgHeap.st_wp",
"Prims.unit",
"AlgHeap.soundness_aux",
"AlgHeap.state",
"FStar.Pervasives.Native.tuple2",
"FStar.Monotonic.Pure.as_pure_wp"
] | [] | false | true | false | false | false | let soundness #a #wp (t: (unit -> AlgWP a wp))
: Tot (s0: state -> ID5.ID (a & state) (as_pure_wp (wp s0))) =
| soundness_aux (reify (t ())) | false |
AlgHeap.fst | AlgHeap.interp_sem | val interp_sem (#a: _) (t: rwtree a) (s0: state)
: ID5.ID (a & state) (as_pure_wp (interp_as_wp t s0)) | val interp_sem (#a: _) (t: rwtree a) (s0: state)
: ID5.ID (a & state) (as_pure_wp (interp_as_wp t s0)) | let rec interp_sem #a (t : rwtree a) (s0:state)
: ID5.ID (a & state) (as_pure_wp (interp_as_wp t s0))
= match t with
| Return x -> (x, s0)
| Op Read i k ->
interp_sem (k s0) s0
| Op Write i k ->
interp_sem (k ()) i | {
"file_name": "examples/layeredeffects/AlgHeap.fst",
"git_rev": "10183ea187da8e8c426b799df6c825e24c0767d3",
"git_url": "https://github.com/FStarLang/FStar.git",
"project_name": "FStar"
} | {
"end_col": 25,
"end_line": 443,
"start_col": 0,
"start_line": 436
} | module AlgHeap
(* Essentially a copy of AlgForAll but using a heap for the state *)
open FStar.Tactics.V2
open FStar.List.Tot
open FStar.Universe
module L = Lattice
module Ghost = FStar.Ghost
module Map = FStar.Map
module T = FStar.Tactics.V2
type loc = int
type state = Map.t loc int
type empty : Type u#aa =
type op =
| Read
| Write
| Raise
| Other of int
assume val other_inp : int -> Type u#0
let op_inp : op -> Type u#0 =
function
| Read -> unit
| Write -> state
| Raise -> exn
| Other i -> other_inp i
assume val other_out : int -> Type u#0
let op_out : op -> Type =
function
| Read -> state
| Write -> unit
| Raise -> empty
| Other i -> other_inp i
noeq
type tree0 (a:Type) : Type =
| Return : a -> tree0 a
| Op : op:op -> i:(op_inp op) -> k:(op_out op -> tree0 a) -> tree0 a
type ops = list op
let rec abides #a (labs:ops) (f : tree0 a) : prop =
begin match f with
| Op a i k ->
mem a labs /\ (forall o. abides labs (k o))
| Return _ -> True
end
type tree (a:Type u#aa)
(labs : list u#0 op)
: Type u#aa
=
r:(tree0 a){abides labs r}
let rec interp_at (l1 l2 : ops) (l : op)
: Lemma (mem l (l1@l2) == (mem l l1 || mem l l2))
[SMTPat (mem l (l1@l2))]
= match l1 with
| [] -> ()
| _::l1 -> interp_at l1 l2 l
let sublist (l1 l2 : ops) = forall x. mem x l1 ==> mem x l2
let rec sublist_at
(l1 l2 : ops)
: Lemma (sublist l1 (l1@l2) /\ sublist l2 (l1@l2))
[SMTPatOr [[SMTPat (sublist l1 (l1@l2))];
[SMTPat (sublist l2 (l1@l2))]]]
= match l1 with
| [] -> ()
| _::l1 -> sublist_at l1 l2
let sublist_at_self
(l : ops)
: Lemma (sublist l (l@l))
[SMTPat (sublist l (l@l))]
= ()
let rec abides_sublist_nopat #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2) c)
= match c with
| Return _ -> ()
| Op a i k ->
let sub o : Lemma (abides l2 (k o)) =
abides_sublist_nopat l1 l2 (k o)
in
Classical.forall_intro sub
let abides_sublist #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c) /\ sublist l1 l2)
(ensures (abides l2 c))
[SMTPat (abides l2 c); SMTPat (sublist l1 l2)]
= abides_sublist_nopat l1 l2 c
let abides_at_self #a
(l : ops)
(c : tree0 a)
: Lemma (abides (l@l) c <==> abides l c)
[SMTPat (abides (l@l) c)]
= (* Trigger some patterns *)
assert (sublist l (l@l));
assert (sublist (l@l) l)
let abides_app #a (l1 l2 : ops) (c : tree0 a)
: Lemma (requires (abides l1 c \/ abides l2 c))
(ensures (abides (l1@l2) c))
[SMTPat (abides (l1@l2) c)]
= sublist_at l1 l2
(* Folding a computation tree *)
val fold_with (#a #b:_) (#labs : ops)
(f:tree a labs)
(v : a -> b)
(h: (o:op{mem o labs} -> op_inp o -> (op_out o -> b) -> b))
: b
let rec fold_with #a #b #labs f v h =
match f with
| Return x -> v x
| Op act i k ->
let k' (o : op_out act) : b =
fold_with #_ #_ #labs (k o) v h
in
h act i k'
let handler_ty_l (o:op) (b:Type) (labs:ops) =
op_inp o -> (op_out o -> tree b labs) -> tree b labs
let handler_ty (labs0 : ops) (b:Type) (labs1 : ops) : Type =
o:op{mem o labs0} -> handler_ty_l o b labs1
(* The most generic handling construct, we use it to implement bind.
It is actually just a special case of folding. *)
val handle_with (#a #b:_) (#labs0 #labs1 : ops)
(f:tree a labs0)
(v : a -> tree b labs1)
(h: handler_ty labs0 b labs1)
: tree b labs1
let handle_with f v h = fold_with f v h
let return (a:Type) (x:a)
: tree a []
= Return x
let bind (a b : Type)
(#labs1 #labs2 : ops)
(c : tree a labs1)
(f : (x:a -> tree b labs2))
: Tot (tree b (labs1@labs2))
= handle_with #_ #_ #labs1 #(labs1@labs2) c f (fun act i k -> Op act i k)
let subcomp (a:Type)
(labs1 labs2 : ops)
(f : tree a labs1)
: Pure (tree a labs2)
(requires (sublist labs1 labs2))
(ensures (fun _ -> True))
= f
let if_then_else
(a : Type)
(labs1 labs2 : ops)
(f : tree a labs1)
(g : tree a labs2)
(p : bool)
: Type
= tree a (labs1@labs2)
let _get : tree state [Read] = Op Read () Return
let _put (s:state) : tree unit [Write] = Op Write s Return
total // need this for catch!!
reifiable
reflectable
effect {
Alg (a:Type) (_:ops)
with {repr = tree; return; bind; subcomp; if_then_else}
}
let get () : Alg state [Read] =
Alg?.reflect _get
let lift_pure_eff
(a:Type)
(wp : pure_wp a)
(f : unit -> PURE a wp)
: Pure (tree a [])
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp;
Return (f ())
sub_effect PURE ~> Alg = lift_pure_eff
let put (s:state) : Alg unit [Write] =
Alg?.reflect (_put s)
let raise #a (e:exn) : Alg a [Raise] =
Alg?.reflect (Op Raise e (fun e -> match e with))
// funnily enough, the version below also succeeds from concluding
// a==empty under the lambda since the context becomes inconsistent
//Alg?.reflect (Op Raise e Return
type rwtree a = tree a [Read;Write]
let tbind : #a:_ -> #b:_ -> rwtree a -> (a -> rwtree b) -> rwtree b = fun c f -> bind _ _ c f
let st_wp0 (a:Type) : Type = state -> (a & state -> Type0) -> Type0
let st_monotonic #a (w : st_wp0 a) : Type0 =
//forall s0 p1 p2. (forall r. p1 r ==> p2 r) ==> w s0 p1 ==> w s0 p2
// ^ this version seems to be less SMT-friendly
forall s0 p1 p2. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> w s0 p1 ==> w s0 p2
let st_wp (a:Type) = wp:st_wp0 a{st_monotonic wp}
unfold
let return_wp #a x : st_wp a = fun s0 p -> p (x, s0)
unfold
let bind_wp #a #b (w : st_wp a) (wf : a -> st_wp b)
: st_wp b
= fun s0 p -> w s0 (fun (y, s1) -> wf y s1 p)
unfold
let read_wp : st_wp state = fun s0 p -> p (s0, s0)
unfold
let write_wp : state -> st_wp unit = fun s _ p -> p ((), s)
(* Also doable with handlers *)
let rec interp_as_wp #a (t : rwtree a) : st_wp a =
match t with
| Return x -> return_wp x
| Op Read _ k ->
bind_wp read_wp (fun s -> interp_as_wp (k s))
| Op Write s k ->
bind_wp (write_wp s) (fun (o:unit) -> interp_as_wp (k o))
let rec interp_rdwr_tree #a (t : tree a [Read;Write]) (s:state) : Tot (a & state) =
match t with
| Return x -> (x, s)
| Op Read _ k ->
interp_rdwr_tree (k s) s
| Op Write s k ->
interp_rdwr_tree (k ()) s
let interp_as_fun #a (t : rwtree a) : (state -> a & state) =
interp_rdwr_tree t
(* Bug: defining this as a FStar.Preorder.preorder
causes stupid failures ahead *)
val stronger : (#a:Type) -> st_wp a -> st_wp a -> Type0
let stronger w1 w2 = forall p s. w1 p s ==> w2 p s
let equiv #a (w1 w2 : st_wp a) = w1 `stronger` w2 /\ w2 `stronger` w1
let (<<=) = stronger
val interp_ret (#a:Type) (x:a) : Lemma (return_wp x `stronger` interp_as_wp (Return x))
let interp_ret x = ()
let wp_is_monotonic #a (wp : st_wp a) : Type0 =
forall p1 p2 s0. (forall x s1. p1 (x, s1) ==> p2 (x, s1)) ==> wp s0 p1 ==> wp s0 p2
let bind_preserves_mon #a #b (wp : st_wp a) (f : a -> st_wp b)
: Lemma (requires (wp_is_monotonic wp /\ (forall x. wp_is_monotonic (f x))))
(ensures (wp_is_monotonic (bind_wp wp f)))
= ()
let rec interp_monotonic #a (c:rwtree a) : Lemma (wp_is_monotonic (interp_as_wp c)) =
match c with
| Return x -> ()
| Op Read _ k ->
let aux (x:state) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon read_wp (fun x -> interp_as_wp (k x))
| Op Write s k ->
let aux (x:unit) : Lemma (wp_is_monotonic (interp_as_wp (k x))) =
interp_monotonic (k x)
in
Classical.forall_intro aux;
bind_preserves_mon (write_wp s) (fun x -> interp_as_wp (k x))
let elim_str #a (w1 w2 : st_wp a) (p : (a & state -> Type0)) (s0:state)
: Lemma (requires (w1 <<= w2))
(ensures w1 s0 p ==> w2 s0 p)
= ()
(* Takes a while *)
let rec interp_morph #a #b (c : rwtree a) (f : a -> rwtree b) (p:_) (s0:_)
: Lemma (interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p) == interp_as_wp (tbind c f) s0 p)
= match c with
| Return x -> ()
| Op Read _ k ->
let aux (o:state) : Lemma (interp_as_wp (k o) s0 (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s0 p) =
interp_morph (k o) f p s0
in
Classical.forall_intro aux
| Op Write s k ->
let aux (o:unit) : Lemma (interp_as_wp (k o) s (fun (y, s1) -> interp_as_wp (f y) s1 p)
== interp_as_wp (tbind (k o) f) s p) =
interp_morph (k o) f p s
in
Classical.forall_intro aux
| _ -> () // this branch is unreachable
val interp_bind (#a #b:Type)
(c : rwtree a) (f : a -> rwtree b)
(w1 : st_wp a) (w2 : a -> st_wp b)
: Lemma (requires w1 <<= interp_as_wp c /\ (forall x. w2 x <<= interp_as_wp (f x)))
(ensures bind_wp w1 w2 `stronger` interp_as_wp (tbind c f))
let interp_bind #a #b c f w1 w2 =
let aux (p: (b & state -> Type0)) (s0:state) : Lemma (bind_wp w1 w2 s0 p ==> interp_as_wp (tbind c f) s0 p) =
calc (==>) {
bind_wp w1 w2 s0 p;
==> {}
w1 s0 (fun (y, s1) -> w2 y s1 p);
==> { (* hyp *)}
interp_as_wp c s0 (fun (y, s1) -> w2 y s1 p);
==> { interp_monotonic c }
interp_as_wp c s0 (fun (y, s1) -> interp_as_wp (f y) s1 p);
==> { interp_morph c f p s0 }
interp_as_wp (tbind c f) s0 p;
}
in
Classical.forall_intro_2 aux
let repr (a : Type) (w: st_wp a) =
c:(rwtree a){w `stronger` interp_as_wp c}
let return2 (a:Type) (x:a) : repr a (return_wp x) =
interp_ret x;
Return x
let bind2 (a : Type) (b : Type)
(wp_v : st_wp a) (wp_f: a -> st_wp b)
(v : repr a wp_v) (f : (x:a -> repr b (wp_f x)))
: repr b (bind_wp wp_v wp_f) =
interp_bind v f wp_v wp_f;
tbind v f
let subcomp2 (a:Type) (w1 w2: st_wp a)
(f : repr a w1)
: Pure (repr a w2)
(requires w2 `stronger` w1)
(ensures fun _ -> True)
= f
let if_then_else2 (a : Type) (w1 w2 : st_wp a)
(f : repr a w1) (g : repr a w2) (b : bool) : Type =
repr a (if b then w1 else w2)
total
reifiable
reflectable
effect {
AlgWP (a:Type) (_:st_wp a)
with {repr;
return = return2;
bind = bind2;
subcomp = subcomp2;
if_then_else = if_then_else2}
}
let get2 () : AlgWP state read_wp =
AlgWP?.reflect _get
let put2 (s:state) : AlgWP unit (write_wp s) =
AlgWP?.reflect (_put s)
open FStar.Monotonic.Pure
unfold
let lift_pure_wp (#a:Type) (wp : pure_wp a) : st_wp a =
elim_pure_wp_monotonicity wp;
fun s0 p -> wp (fun x -> p (x, s0))
let lift_pure_algwp (a:Type) wp (f:unit -> PURE a wp)
: Pure (repr a (lift_pure_wp wp)) // can't call f() here, so lift its wp instead
(requires (wp (fun _ -> True)))
(ensures (fun _ -> True))
= let v : a = elim_pure f (fun _ -> True) in
FStar.Monotonic.Pure.elim_pure_wp_monotonicity wp; // need this lemma
assert (forall p. wp p ==> p v); // this is key fact needed for the proof
assert_norm (stronger (lift_pure_wp wp) (return_wp v));
Return v
sub_effect PURE ~> AlgWP = lift_pure_algwp
let sel (r:loc) : AlgWP int (fun h0 p -> p (Map.sel h0 r, h0)) =
let h = get2 () in
Map.sel h r
let upd (r:loc) (v:int) : AlgWP unit (fun h0 p -> p ((), Map.upd h0 r v)) =
let h = get2 () in
put2 (Map.upd h r v)
let (!) = sel
let (:=) = upd
let modifies1 (l:loc) (h0 h1 : state) : Type0 =
forall y. y <> l ==> Map.sel h0 y == Map.sel h1 y
let modifies (ls: list loc) (h0 h1 : state) : Type0 =
forall y. mem y ls \/ (Map.sel h0 y == Map.sel h1 y)
effect AlgPP (a:Type) (pre : state -> Type0) (post : state -> a -> state -> Type0) =
AlgWP a (fun h0 p -> pre h0 /\ (forall y h1. post h0 y h1 ==> p (y, h1)))
let addx (l:loc) (x:int) : AlgPP unit (fun _ -> True) (fun h0 _ h1 -> modifies1 l h0 h1
/\ (Map.sel h1 l == x + Map.sel h0 l)) =
l := !l + x
let swap (l1 l2 : loc) : AlgPP unit (fun _ -> l1 <> l2)
(fun h0 _ h1 ->
modifies [l1;l2] h0 h1 /\
Map.sel h1 l1 == Map.sel h0 l2 /\
Map.sel h1 l2 == Map.sel h0 l1)
=
let r = !l2 in
l2 := !l1;
l1 := r | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"Lattice.fst.checked",
"ID5.fst.checked",
"FStar.Universe.fsti.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Monotonic.Pure.fst.checked",
"FStar.Map.fsti.checked",
"FStar.List.Tot.fst.checked",
"FStar.Ghost.fsti.checked",
"FStar.Classical.fsti.checked",
"FStar.Calc.fsti.checked"
],
"interface_file": false,
"source_file": "AlgHeap.fst"
} | [
{
"abbrev": false,
"full_module": "FStar.Monotonic.Pure",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Map",
"short_module": "Map"
},
{
"abbrev": true,
"full_module": "FStar.Ghost",
"short_module": "Ghost"
},
{
"abbrev": true,
"full_module": "Lattice",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Universe",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.List.Tot",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Tactics.V2",
"short_module": null
},
{
"abbrev": 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 | t: AlgHeap.rwtree a -> s0: AlgHeap.state -> ID5.ID (a * AlgHeap.state) | ID5.ID | [] | [] | [
"AlgHeap.rwtree",
"AlgHeap.state",
"FStar.Pervasives.Native.Mktuple2",
"FStar.Pervasives.Native.tuple2",
"AlgHeap.op_inp",
"AlgHeap.Read",
"AlgHeap.op_out",
"AlgHeap.tree0",
"AlgHeap.interp_sem",
"AlgHeap.Write",
"FStar.Monotonic.Pure.as_pure_wp",
"AlgHeap.interp_as_wp"
] | [
"recursion"
] | false | true | false | false | false | let rec interp_sem #a (t: rwtree a) (s0: state)
: ID5.ID (a & state) (as_pure_wp (interp_as_wp t s0)) =
| match t with
| Return x -> (x, s0)
| Op Read i k -> interp_sem (k s0) s0
| Op Write i k -> interp_sem (k ()) i | false |
LowParse.SLow.BCVLI.fst | LowParse.SLow.BCVLI.size32_bounded_bcvli | val size32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (size32 (serialize_bounded_bcvli min max)) | val size32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (size32 (serialize_bounded_bcvli min max)) | let size32_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (size32 (serialize_bounded_bcvli min max))
= fun x -> ((
[@inline_let]
let _ = serialize_bounded_bcvli_eq min max x in
size32_bcvli x
) <: (res: _ { size32_postcond (serialize_bounded_bcvli min max) x res })) | {
"file_name": "src/lowparse/LowParse.SLow.BCVLI.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 76,
"end_line": 147,
"start_col": 0,
"start_line": 139
} | module LowParse.SLow.BCVLI
include LowParse.Spec.BCVLI
include LowParse.SLow.Combinators // for make_total_constant_size_parser32
include LowParse.SLow.BoundedInt // for bounded_integer_le
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
module Cast = FStar.Int.Cast
#push-options "--max_fuel 0"
let parse32_bcvli
: parser32 parse_bcvli
= fun input -> ((
[@inline_let] let _ =
parse_bcvli_eq (B32.reveal input)
in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul
then Some (x32, consumed_x)
else
let input' = B32.slice input consumed_x (B32.len input) in
if x32 = 253ul
then
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 253ul then None else Some (y, consumed_x `U32.add` consumed_y)
else if x32 = 254ul
then
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 65536ul then None else Some (y, consumed_x `U32.add` consumed_y)
else
None
) <: (res: _ { parser32_correct parse_bcvli input res } ))
module U8 = FStar.UInt8
let serialize32_bcvli
: serializer32 serialize_bcvli
= fun x -> ((
[@inline_let] let _ = serialize_bcvli_eq x in
let c1 : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
let s1 = serialize32_bounded_integer_le_1 c1 in
if c1 `U32.lt` 253ul
then s1
else if c1 = 253ul
then s1 `B32.append` serialize32_bounded_integer_le_2 x
else s1 `B32.append` serialize32_bounded_integer_le_4 x
) <: (res: bytes32 { serializer32_correct' serialize_bcvli x res } ))
let size32_bcvli
: size32 serialize_bcvli
= fun x -> ((
[@inline_let] let _ = serialize_bcvli_eq x in
if x `U32.lt` 253ul
then 1ul
else if x `U32.lt` 65536ul
then 3ul
else 5ul
) <: (res: _ { size32_postcond serialize_bcvli x res } ))
inline_for_extraction
let parse32_bounded_bcvli
(min: nat)
(min32: U32.t { U32.v min32 == min })
(max: nat { min <= max })
(max32: U32.t { U32.v max32 == max })
: Tot (parser32 (parse_bounded_bcvli min max))
= fun input -> ((
[@inline_let]
let _ = parse_bounded_bcvli_eq min max (B32.reveal input) in
[@inline_let]
let _ = parse_bcvli_eq (B32.reveal input) in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul && min32 `U32.lte` x32 && x32 `U32.lte` max32
then Some (x32, consumed_x)
else if max32 `U32.lt` 253ul
then None
else
if x32 = 253ul
then
if 65536ul `U32.lte` min32
then None
else
let input' = B32.slice input consumed_x (B32.len input) in
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if
y `U32.lt` 253ul || y `U32.lt` min32 || max32 `U32.lt` y
then
None
else
Some (y, consumed_x `U32.add` consumed_y)
else if max32 `U32.lt` 65536ul
then None
else if x32 = 254ul
then
let input' = B32.slice input consumed_x (B32.len input) in
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if
y `U32.lt` 65536ul || y `U32.lt` min32 || max32 `U32.lt` y
then
None
else
Some (y, consumed_x `U32.add` consumed_y)
else
None
) <: (res: _ { parser32_correct (parse_bounded_bcvli min max) input res }))
inline_for_extraction
let serialize32_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (serializer32 (serialize_bounded_bcvli min max))
= fun x -> ((
[@inline_let]
let _ = serialize_bounded_bcvli_eq min max x in
serialize32_bcvli x
) <: (res: _ { serializer32_correct (serialize_bounded_bcvli min max) x res })) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.SLow.BoundedInt.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.BCVLI.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | min: Prims.nat -> max: Prims.nat{min <= max}
-> LowParse.SLow.Base.size32 (LowParse.Spec.BCVLI.serialize_bounded_bcvli min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.SLow.BCVLI.size32_bcvli",
"Prims.unit",
"LowParse.Spec.BCVLI.serialize_bounded_bcvli_eq",
"FStar.UInt32.t",
"LowParse.SLow.Base.size32_postcond",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bounded_bcvli",
"LowParse.Spec.BCVLI.serialize_bounded_bcvli",
"LowParse.SLow.Base.size32"
] | [] | false | false | false | false | false | let size32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (size32 (serialize_bounded_bcvli min max)) =
| fun x ->
(([@@ inline_let ]let _ = serialize_bounded_bcvli_eq min max x in
size32_bcvli x)
<:
(res: _{size32_postcond (serialize_bounded_bcvli min max) x res})) | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_from_bytes_le_f | val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w | val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w | let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w)) | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 79,
"end_line": 16,
"start_col": 0,
"start_line": 15
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
vt: Lib.IntVector.v_inttype ->
w: Lib.IntVector.width ->
len: Prims.nat{len * (Lib.IntTypes.numbytes vt * w) <= Lib.IntTypes.max_size_t} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 (len * (Lib.IntTypes.numbytes vt * w)) ->
i: Prims.nat{i < len}
-> Lib.IntVector.vec_t vt w | Prims.Tot | [
"total"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Prims.op_LessThan",
"Lib.IntVector.vec_from_bytes_le",
"Lib.Sequence.sub",
"Lib.IntVector.vec_t"
] | [] | false | false | false | false | false | let vecs_from_bytes_le_f vt w len b i =
| vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w)) | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_from_bytes_be | val vecs_from_bytes_be: vt:v_inttype -> w:width -> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w)) -> lseq (vec_t vt w) len | val vecs_from_bytes_be: vt:v_inttype -> w:width -> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w)) -> lseq (vec_t vt w) len | let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b) | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 36,
"start_col": 0,
"start_line": 35
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
vt: Lib.IntVector.v_inttype ->
w: Lib.IntVector.width ->
len: Prims.nat{len * (Lib.IntTypes.numbytes vt * w) <= Lib.IntTypes.max_size_t} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 (len * (Lib.IntTypes.numbytes vt * w))
-> Lib.Sequence.lseq (Lib.IntVector.vec_t vt w) len | Prims.Tot | [
"total"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Lib.Sequence.createi",
"Lib.IntVector.vec_t",
"Lib.IntVector.Serialize.vecs_from_bytes_be_f"
] | [] | false | false | false | false | false | let vecs_from_bytes_be vt w len b =
| LSeq.createi len (vecs_from_bytes_be_f vt w len b) | false |
Vale.AES.X64.GCMdecryptOpt.fst | Vale.AES.X64.GCMdecryptOpt.va_wp_Gcm_blocks | val va_wp_Gcm_blocks
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | val va_wp_Gcm_blocks
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 | let va_wp_Gcm_blocks (alg:algorithm) (offset:int) (auth_b:buffer128) (abytes_b:buffer128)
(in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128) (out128_b:buffer128)
(inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit ->
Type0)) : Type0 =
(va_get_ok va_s0 /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in sse_enabled /\
movbe_enabled /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64
(va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\ (forall (va_x_mem:vale_heap)
(va_x_rax:nat64) (va_x_rbx:nat64) (va_x_rcx:nat64) (va_x_rdx:nat64) (va_x_rdi:nat64)
(va_x_rsi:nat64) (va_x_rbp:nat64) (va_x_r8:nat64) (va_x_r9:nat64) (va_x_r10:nat64)
(va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_r15:nat64)
(va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32)
(va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32)
(va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32)
(va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap1:vale_heap) (va_x_heap2:vale_heap)
(va_x_heap3:vale_heap) (va_x_heap5:vale_heap) (va_x_heap6:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 6
va_x_heap6 (va_upd_mem_heaplet 5 va_x_heap5 (va_upd_mem_heaplet 3 va_x_heap3
(va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 15 va_x_xmm15
(va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11
va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8
(va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4
(va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0
(va_upd_reg64 rR15 va_x_r15 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13
(va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rR10 va_x_r10
(va_upd_reg64 rR9 va_x_r9 (va_upd_reg64 rR8 va_x_r8 (va_upd_reg64 rRbp va_x_rbp (va_upd_reg64
rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRcx
va_x_rcx (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem
va_s0))))))))))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = va_if
(plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) (fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM)
inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) in let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128)
`op_Multiply` 128 `op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 +
len128) in Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let
(length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64
rRsi va_s0) in let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits
auth_input_bytes in let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32
padded_auth_bytes in let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32 auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0)
in128x6_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat)
= FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) (fun
_ -> raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32
raw_quad_seq (FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) ==> va_k va_sM (()))) | {
"file_name": "obj/Vale.AES.X64.GCMdecryptOpt.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 34,
"end_line": 1285,
"start_col": 0,
"start_line": 1120
} | module Vale.AES.X64.GCMdecryptOpt
open Vale.Def.Prop_s
open Vale.Def.Opaque_s
open FStar.Seq
open Vale.Def.Words_s
open Vale.Def.Words.Seq_s
open Vale.Def.Types_s
open Vale.Arch.Types
open Vale.Arch.HeapImpl
open Vale.AES.AES_s
open Vale.AES.GCTR_s
open Vale.AES.GCTR
open Vale.AES.GCM
open Vale.AES.GHash_s
open Vale.AES.GHash
open Vale.AES.GCM_s
open Vale.AES.X64.AES
open Vale.AES.GF128_s
open Vale.AES.GF128
open Vale.Poly1305.Math
open Vale.AES.GCM_helpers
open Vale.AES.X64.GHash
open Vale.AES.X64.GCTR
open Vale.X64.Machine_s
open Vale.X64.Memory
open Vale.X64.Stack_i
open Vale.X64.State
open Vale.X64.Decls
open Vale.X64.InsBasic
open Vale.X64.InsMem
open Vale.X64.InsVector
open Vale.X64.InsStack
open Vale.X64.InsAes
open Vale.X64.QuickCode
open Vale.X64.QuickCodes
open Vale.AES.X64.GF128_Mul
open Vale.X64.Stack
open Vale.X64.CPU_Features_s
open Vale.Math.Poly2.Bits_s
open Vale.AES.X64.AESopt
open Vale.AES.X64.AESGCM
open Vale.AES.X64.AESopt2
open Vale.Lib.Meta
open Vale.AES.X64.GCMencryptOpt
open Vale.AES.OptPublic
open Vale.Lib.Basic
#reset-options "--z3rlimit 20 --max_ifuel 0"
//-- Gcm_extra_bytes
val va_code_Gcm_extra_bytes : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_extra_bytes alg =
(va_Block (va_CCons (va_code_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_CCons (va_code_Mov128 (va_op_xmm_xmm 10)
(va_op_xmm_xmm 0)) (va_CCons (va_code_Ghash_extra_bytes ()) (va_CCons (va_code_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_CCons (va_code_Pshufb (va_op_xmm_xmm 0)
(va_op_xmm_xmm 9)) (va_CCons (va_code_AESEncryptBlock alg) (va_CCons (va_code_Pxor
(va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_CCons (va_code_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_CNil ()))))))))))
val va_codegen_success_Gcm_extra_bytes : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_extra_bytes alg =
(va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0)
(va_op_reg_opr64_reg64 rRax) 0 Secret) (va_pbool_and (va_codegen_success_Mov128 (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Ghash_extra_bytes ()) (va_pbool_and
(va_codegen_success_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_pbool_and
(va_codegen_success_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and
(va_codegen_success_AESEncryptBlock alg) (va_pbool_and (va_codegen_success_Pxor (va_op_xmm_xmm
10) (va_op_xmm_xmm 0)) (va_pbool_and (va_codegen_success_Store128_buffer
(va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax) (va_op_xmm_xmm 10) 0 Secret)
(va_ttrue ())))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_extra_bytes (va_mods:va_mods_t) (alg:algorithm) (inout_b:buffer128) (key:(seq
nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat)
(old_hash:quad32) (completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit
(va_code_Gcm_extra_bytes alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let (len:(va_int_range
1 1)) = 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 188 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRax) 0 Secret inout_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 189 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (fun (va_s:va_state) _ -> let
(hash_input:quad32) = va_get_xmm 0 va_s in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 193 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_extra_bytes hkeys_b total_bytes old_hash h_LE completed_quads) (fun
(va_s:va_state) _ -> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 194 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.equal #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s)
inout_b) (FStar.Seq.Base.create #quad32 1 hash_input)) (let (snap:(FStar.Seq.Base.seq
Vale.X64.Decls.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QSeq
va_range1
"***** PRECONDITION NOT MET AT line 198 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 11)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 199 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> va_QBind
va_range1
"***** PRECONDITION NOT MET AT line 200 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AESEncryptBlock alg (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 11 va_s)) key
round_keys keys_b) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 201 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.AES_s.aes_encrypt_LE_reveal ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 204 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pxor (va_op_xmm_xmm 10) (va_op_xmm_xmm 0)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 205 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 5) (va_op_reg_opr64_reg64 rRax)
(va_op_xmm_xmm 10) 0 Secret inout_b 0) (fun (va_s:va_state) _ -> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 207 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_reveal ()) (va_QEmpty (()))))))))))))))
val va_lemma_Gcm_extra_bytes : va_b0:va_code -> va_s0:va_state -> alg:algorithm ->
inout_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> total_bytes:nat -> old_hash:quad32 -> completed_quads:(seq quad32) ->
h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_extra_bytes alg) va_s0 /\ va_get_ok va_s0 /\ (let
(len:(va_int_range 1 1)) = 1 in sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b
inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b inout_b /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax va_s0) inout_b
len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) /\ va_state_eq va_sM
(va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM (va_update_ok va_sM
(va_update_mem va_sM va_s0))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_extra_bytes va_b0 va_s0 alg inout_b key round_keys keys_b hkeys_b total_bytes
old_hash completed_quads h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_extra_bytes va_mods alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_extra_bytes alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 121 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (len:(va_int_range 1 1)) = 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 174 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 177 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg len (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0)) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 180 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let raw_quads = FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 181 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 182 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let padded_bytes = Vale.AES.GCTR_s.pad_to_128_bits input_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 183 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let input_quads = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 186 column 59 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(l_and (FStar.Seq.Base.length #Vale.Def.Types_s.quad32 input_quads > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE old_hash input_quads)))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) (va_s0:va_state) (va_k:(va_state -> unit -> Type0))
: Type0 =
(va_get_ok va_s0 /\ (let (len:(va_int_range 1 1)) = 1 in sse_enabled /\
Vale.X64.Decls.buffers_disjoint128 keys_b inout_b /\ Vale.X64.Decls.buffers_disjoint128 hkeys_b
inout_b /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) (va_get_reg64 rRax
va_s0) inout_b len (va_get_mem_layout va_s0) Secret /\ len == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 inout_b /\ va_get_xmm 9 va_s0 == Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ aes_reqs alg key round_keys
keys_b (va_get_reg64 rR8 va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\
pclmulqdq_enabled /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0
va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret /\ va_get_xmm 8 va_s0 == Vale.Def.Types_s.reverse_bytes_quad32
(Vale.AES.GHash.ghash_incremental0 h_LE old_hash completed_quads) /\ FStar.Seq.Base.length
#quad32 completed_quads == total_bytes `op_Division` 16 /\ total_bytes < 16 `op_Multiply`
FStar.Seq.Base.length #quad32 completed_quads + 16 /\ va_get_reg64 rR10 va_s0 == total_bytes
`op_Modulus` 16 /\ total_bytes `op_Modulus` 16 =!= 0 /\ (0 < total_bytes /\ total_bytes < 16
`op_Multiply` Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes) /\ 16 `op_Multiply`
(Vale.AES.GCM_helpers.bytes_to_quad_size total_bytes - 1) < total_bytes) /\ (forall
(va_x_mem:vale_heap) (va_x_rcx:nat64) (va_x_r11:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm10:quad32) (va_x_heap5:vale_heap)
(va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 5
va_x_heap5 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7
(va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3
(va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR11
va_x_r11 (va_upd_reg64 rRcx va_x_rcx (va_upd_mem va_x_mem va_s0)))))))))))))) in va_get_ok
va_sM /\ (let (len:(va_int_range 1 1)) = 1 in Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5 va_sM) /\ Vale.AES.GCTR.gctr_partial alg len
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b) key (va_get_xmm 11 va_s0) /\ (let raw_quads =
FStar.Seq.Base.append #quad32 completed_quads (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0)
inout_b) in let input_bytes = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_quads) 0 total_bytes in let padded_bytes =
Vale.AES.GCTR_s.pad_to_128_bits input_bytes in let input_quads =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_bytes in l_and (FStar.Seq.Base.length
#Vale.Def.Types_s.quad32 input_quads > 0) (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_sM) == Vale.AES.GHash.ghash_incremental h_LE old_hash input_quads))) ==> va_k va_sM (())))
val va_wpProof_Gcm_extra_bytes : alg:algorithm -> inout_b:buffer128 -> key:(seq nat32) ->
round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> total_bytes:nat ->
old_hash:quad32 -> completed_quads:(seq quad32) -> h_LE:quad32 -> va_s0:va_state ->
va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_extra_bytes alg) ([va_Mod_flags;
va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5;
va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11;
va_Mod_reg64 rRcx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_extra_bytes (va_code_Gcm_extra_bytes alg) va_s0 alg inout_b key
round_keys keys_b hkeys_b total_bytes old_hash completed_quads h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 5 va_sM (va_update_xmm 10
va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRcx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10; va_Mod_xmm 8; va_Mod_xmm
7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1;
va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_extra_bytes (alg:algorithm) (inout_b:buffer128) (key:(seq nat32)) (round_keys:(seq
quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (total_bytes:nat) (old_hash:quad32)
(completed_quads:(seq quad32)) (h_LE:quad32) : (va_quickCode unit (va_code_Gcm_extra_bytes alg)) =
(va_QProc (va_code_Gcm_extra_bytes alg) ([va_Mod_flags; va_Mod_mem_heaplet 5; va_Mod_xmm 10;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR11; va_Mod_reg64 rRcx; va_Mod_mem])
(va_wp_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes old_hash
completed_quads h_LE) (va_wpProof_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b
total_bytes old_hash completed_quads h_LE))
//--
//-- Gcm_blocks128
val va_code_Gcm_blocks128 : alg:algorithm -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks128 alg =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_CCons
(va_code_Ghash_buffer ()) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdi)
(va_op_opr64_reg64 rRbx)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRdx)
(va_op_opr64_reg64 rR12)) (va_CCons (va_code_Gctr_blocks128 alg) (va_CNil ())))))))))
val va_codegen_success_Gcm_blocks128 : alg:algorithm -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks128 alg =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx))
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax))
(va_pbool_and (va_codegen_success_Ghash_buffer ()) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_pbool_and
(va_codegen_success_Gctr_blocks128 alg) (va_ttrue ()))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks128 (va_mods:va_mods_t) (alg:algorithm) (in_b:buffer128) (out_b:buffer128)
(key:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32)
: (va_quickCode unit (va_code_Gcm_blocks128 alg)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 274 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRbx) (va_op_opr64_reg64 rRdi)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 275 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR12) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 276 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRax)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 277 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_buffer hkeys_b in_b h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8
va_old_s))) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 278 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdi) (va_op_opr64_reg64 rRbx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 279 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRdx) (va_op_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 280 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_blocks128 alg in_b out_b key round_keys keys_b) (va_QEmpty (()))))))))))
val va_lemma_Gcm_blocks128 : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> in_b:buffer128 ->
out_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128 -> h_LE:quad32
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks128 alg) va_s0 /\ va_get_ok va_s0 /\
(sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret)))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) /\ va_state_eq va_sM (va_update_flags va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 10 va_sM (va_update_xmm 11 va_sM (va_update_xmm 8
va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4
va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0
va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM
(va_update_reg64 rR11 va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM
(va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks128 va_b0 va_s0 alg in_b out_b key round_keys keys_b hkeys_b h_LE =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11;
va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm
2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks128 va_mods alg in_b out_b key round_keys keys_b hkeys_b h_LE in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks128 alg) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 210 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (label va_range1
"***** POSTCONDITION NOT MET AT line 255 column 53 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 261 column 95 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 262 column 45 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0) (va_get_reg64 rRdx
va_s0)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 265 column 93 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM == va_get_xmm 8 va_s0)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b == Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) out_b)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 267 column 131 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRdx va_s0 > 0 ==> l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==>
FStar.Seq.Base.length #Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM)
[@ va_qattr]
let va_wp_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) (va_s0:va_state)
(va_k:(va_state -> unit -> Type0)) : Type0 =
(va_get_ok va_s0 /\ (sse_enabled /\ Vale.X64.Decls.buffers_disjoint128 keys_b out_b /\
Vale.X64.Decls.buffers_disjoint128 hkeys_b out_b /\ (Vale.X64.Decls.buffers_disjoint128 in_b
out_b \/ in_b == out_b) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRax va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0) (va_get_reg64 rRdi va_s0) out_b
(va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ va_get_reg64 rRax va_s0 + 16
`op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply`
va_get_reg64 rRdx va_s0 < pow2_64 /\ l_and (Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b)
(Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b < pow2_32) /\ va_get_reg64 rRdx
va_s0 == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b /\ va_get_xmm 9 va_s0 ==
Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\
va_get_reg64 rRdx va_s0 < pow2_32 /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rR8
va_s0) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ Vale.X64.Decls.validSrcAddrs128
(va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0)
Secret) /\ (forall (va_x_mem:vale_heap) (va_x_rbx:nat64) (va_x_rdi:nat64) (va_x_r11:nat64)
(va_x_r10:nat64) (va_x_rdx:nat64) (va_x_r12:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32)
(va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32)
(va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm11:quad32) (va_x_xmm10:quad32)
(va_x_heap1:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl
(va_upd_mem_heaplet 1 va_x_heap1 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 11 va_x_xmm11
(va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5
(va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1
(va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64
rR10 va_x_r10 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRbx
va_x_rbx (va_upd_mem va_x_mem va_s0))))))))))))))))))) in va_get_ok va_sM /\
(Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM) /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b) key
(va_get_xmm 11 va_s0) /\ va_get_xmm 11 va_sM == Vale.AES.GCTR.inc32lite (va_get_xmm 11 va_s0)
(va_get_reg64 rRdx va_s0) /\ (va_get_reg64 rRdx va_s0 == 0 ==> l_and (va_get_xmm 8 va_sM ==
va_get_xmm 8 va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out_b ==
Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) out_b)) /\ (va_get_reg64 rRdx va_s0 > 0 ==>
l_and (va_get_reg64 rRdx va_s0 <= FStar.Seq.Base.length #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in_b) ==> FStar.Seq.Base.length
#Vale.X64.Decls.quad32 (FStar.Seq.Base.slice #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b) 0 (va_get_reg64 rRdx va_s0)) > 0)
(Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental
h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in_b)))) ==> va_k va_sM (())))
val va_wpProof_Gcm_blocks128 : alg:algorithm -> in_b:buffer128 -> out_b:buffer128 -> key:(seq
nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> h_LE:quad32 ->
va_s0:va_state -> va_k:(va_state -> unit -> Type0)
-> Ghost (va_state & va_fuel & unit)
(requires (va_t_require va_s0 /\ va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b
h_LE va_s0 va_k))
(ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_Gcm_blocks128 alg) ([va_Mod_flags;
va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6;
va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0;
va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi;
va_Mod_reg64 rRbx; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g))))
[@"opaque_to_smt"]
let va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE va_s0 va_k =
let (va_sM, va_f0) = va_lemma_Gcm_blocks128 (va_code_Gcm_blocks128 alg) va_s0 alg in_b out_b key
round_keys keys_b hkeys_b h_LE in
va_lemma_upd_update va_sM;
assert (va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 1 va_sM (va_update_xmm 10
va_sM (va_update_xmm 11 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6
va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2
va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR12 va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rR10 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rRdi va_sM (va_update_reg64 rRbx va_sM (va_update_ok va_sM (va_update_mem
va_sM va_s0))))))))))))))))))))));
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10; va_Mod_xmm 11; va_Mod_xmm
8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2;
va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64 rR10;
va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem]) va_sM va_s0;
let va_g = () in
(va_sM, va_f0, va_g)
[@ "opaque_to_smt" va_qattr]
let va_quick_Gcm_blocks128 (alg:algorithm) (in_b:buffer128) (out_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (h_LE:quad32) : (va_quickCode
unit (va_code_Gcm_blocks128 alg)) =
(va_QProc (va_code_Gcm_blocks128 alg) ([va_Mod_flags; va_Mod_mem_heaplet 1; va_Mod_xmm 10;
va_Mod_xmm 11; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm
3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR12; va_Mod_reg64 rRdx; va_Mod_reg64
rR10; va_Mod_reg64 rR11; va_Mod_reg64 rRdi; va_Mod_reg64 rRbx; va_Mod_mem])
(va_wp_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE)
(va_wpProof_Gcm_blocks128 alg in_b out_b key round_keys keys_b hkeys_b h_LE))
//--
//-- Gcm_blocks
#push-options "--z3rlimit 1000"
val va_code_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_code
[@ "opaque_to_smt" va_qattr]
let va_code_Gcm_blocks alg offset =
(va_Block (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64
32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp)
(offset + 0)) (va_CCons (va_code_Gcm_blocks_auth ()) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 24)) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13))
(va_CCons (va_code_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public) (va_CCons (va_code_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_CCons (va_code_Load_one_lsb
(va_op_xmm_xmm 10)) (va_CCons (va_code_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1)
(va_op_xmm_xmm 10)) (va_CCons (va_code_AES_GCM_decrypt_6mult alg) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64
rRbp) 32 Secret) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 32)) (va_CCons (va_code_Load64_stack (va_op_dst_opr64_reg64 rRdi)
(va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48)) (va_CCons
(va_code_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_CCons
(va_code_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_CCons
(va_code_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_CCons (va_code_Gcm_blocks128 alg)
(va_CCons (va_code_Stack_lemma ()) (va_CCons (va_code_Add64 (va_op_dst_opr64_reg64 rR14)
(va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public)) (va_CCons (va_code_IMul64
(va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_CCons (va_code_Load64_stack
(va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_CCons (va_IfElse
(va_cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (va_Block (va_CCons
(va_code_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (va_CCons
(va_code_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_CCons
(va_code_Gcm_extra_bytes alg) (va_CCons (va_Block (va_CNil ())) (va_CNil ()))))))) (va_Block
(va_CNil ()))) (va_CCons (va_code_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15))
(va_CCons (va_code_Gcm_make_length_quad ()) (va_CCons (va_code_Ghash_register ()) (va_CCons
(va_code_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret) (va_CCons (va_code_Gctr_register alg) (va_CCons (va_Block (va_CNil ()))
(va_CNil ()))))))))))))))))))))))))))))))))))))
val va_codegen_success_Gcm_blocks : alg:algorithm -> offset:int -> Tot va_pbool
[@ "opaque_to_smt" va_qattr]
let va_codegen_success_Gcm_blocks alg offset =
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9)
(va_const_opr64 32)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64
rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0)) (va_pbool_and
(va_codegen_success_Gcm_blocks_auth ()) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp)
(offset + 16)) (va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx)
(va_op_reg_opr64_reg64 rRsp) (offset + 24)) (va_pbool_and (va_codegen_success_Mov64
(va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_Mov128
(va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64 rR8) 0 Public)
(va_pbool_and (va_codegen_success_Store128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_reg_opr64_reg64 rRbp) (va_op_xmm_xmm 1) 0 Secret) (va_pbool_and
(va_codegen_success_Load_one_lsb (va_op_xmm_xmm 10)) (va_pbool_and (va_codegen_success_VPaddd
(va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_pbool_and
(va_codegen_success_AES_GCM_decrypt_6mult alg) (va_pbool_and (va_codegen_success_Load128_buffer
(va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11) (va_op_reg_opr64_reg64 rRbp) 32 Secret)
(va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax)
(va_op_reg_opr64_reg64 rRsp) (offset + 32)) (va_pbool_and (va_codegen_success_Load64_stack
(va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40)) (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp)
(offset + 48)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR14)
(va_op_opr64_reg64 rRdx)) (va_pbool_and (va_codegen_success_InitPshufbMask (va_op_xmm_xmm 9)
(va_op_reg_opr64_reg64 rR12)) (va_pbool_and (va_codegen_success_Pshufb (va_op_xmm_xmm 11)
(va_op_xmm_xmm 9)) (va_pbool_and (va_codegen_success_Gcm_blocks128 alg) (va_pbool_and
(va_codegen_success_Stack_lemma ()) (va_pbool_and (va_codegen_success_Add64
(va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp) (offset + 24) Public))
(va_pbool_and (va_codegen_success_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16))
(va_pbool_and (va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rR13)
(va_op_reg_opr64_reg64 rRsp) (offset + 64)) (va_pbool_and (va_pbool_and
(va_codegen_success_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp)
(offset + 56)) (va_pbool_and (va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR10)
(va_op_opr64_reg64 rR13)) (va_pbool_and (va_codegen_success_And64 (va_op_dst_opr64_reg64 rR10)
(va_const_opr64 15)) (va_codegen_success_Gcm_extra_bytes alg)))) (va_pbool_and
(va_codegen_success_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_pbool_and
(va_codegen_success_Gcm_make_length_quad ()) (va_pbool_and (va_codegen_success_Ghash_register
()) (va_pbool_and (va_codegen_success_Load128_buffer (va_op_heaplet_mem_heaplet 3)
(va_op_xmm_xmm 0) (va_op_reg_opr64_reg64 rRbp) 0 Secret) (va_pbool_and
(va_codegen_success_Gctr_register alg) (va_ttrue ()))))))))))))))))))))))))))))))))))
[@ "opaque_to_smt" va_qattr]
let va_qcode_Gcm_blocks (va_mods:va_mods_t) (alg:algorithm) (offset:int) (auth_b:buffer128)
(abytes_b:buffer128) (in128x6_b:buffer128) (out128x6_b:buffer128) (in128_b:buffer128)
(out128_b:buffer128) (inout_b:buffer128) (iv_b:buffer128) (scratch_b:buffer128) (key:(seq nat32))
(round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit
(va_code_Gcm_blocks alg offset)) =
(qblock va_mods (fun (va_s:va_state) -> let (va_old_s:va_state) = va_s in let
(abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 0) (va_get_stack va_s) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 8) (va_get_stack va_s) in let
(out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 16) (va_get_stack va_s) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 24) (va_get_stack va_s) in let
(in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s +
offset + 32) (va_get_stack va_s) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 40) (va_get_stack va_s) in let
(len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset
+ 48) (va_get_stack va_s) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s + offset + 56) (va_get_stack va_s) in let
(plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s
+ offset + 64) (va_get_stack va_s) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_old_s)) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 463 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR13) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 464 column 13 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AddLea64 (va_op_dst_opr64_reg64 rR9) (va_op_opr64_reg64 rR9) (va_const_opr64 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 465 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRbx) (va_op_reg_opr64_reg64 rRsp) (offset + 0))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 466 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks_auth auth_b abytes_b hkeys_b h_LE) (fun (va_s:va_state)
(auth_quad_seq:(seq quad32)) -> let (y_0:quad32) = Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0 in let (y_auth_bytes:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 473 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 8))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 474 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRsi) (va_op_reg_opr64_reg64 rRsp) (offset + 16))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 475 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 24))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 476 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rRcx) (va_op_opr64_reg64 rR13)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 477 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov128 (va_op_xmm_xmm 0) (va_op_xmm_xmm 9)) (fun (va_s:va_state) _ -> let
(iv_BE:Vale.X64.Decls.quad32) = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2
va_old_s) in let (ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32
iv_BE 1 in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 483 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 2) (va_op_xmm_xmm 1) (va_op_reg_opr64_reg64
rR8) 0 Public iv_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 485 column 20 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Store128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_reg_opr64_reg64 rRbp)
(va_op_xmm_xmm 1) 0 Secret scratch_b 0) (fun (va_s:va_state) _ -> let (j0:quad32) = va_get_xmm
1 va_s in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 487 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load_one_lsb (va_op_xmm_xmm 10)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 489 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_VPaddd (va_op_xmm_xmm 1) (va_op_xmm_xmm 1) (va_op_xmm_xmm 10)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 491 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_AES_GCM_decrypt_6mult alg h_LE iv_b in128x6_b out128x6_b scratch_b key round_keys
keys_b hkeys_b) (fun (va_s:va_state) _ -> let (y_cipher128x6:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (auth_in:(seq quad32)) =
auth_quad_seq in let (va_arg138:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) =
Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b in let
(va_arg137:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg136:Vale.Def.Types_s.quad32) = y_auth_bytes in let (va_arg135:Vale.Def.Types_s.quad32) =
y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 494 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg135 va_arg136
y_cipher128x6 va_arg137 va_arg138) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 498 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 11)
(va_op_reg_opr64_reg64 rRbp) 32 Secret scratch_b 2) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 499 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR8) (va_op_opr64_reg64 rRcx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 500 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 32))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 501 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdi) (va_op_reg_opr64_reg64 rRsp) (offset + 40))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 502 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRdx) (va_op_reg_opr64_reg64 rRsp) (offset + 48))
(va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 503 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR14) (va_op_opr64_reg64 rRdx)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 504 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_InitPshufbMask (va_op_xmm_xmm 9) (va_op_reg_opr64_reg64 rR12)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 505 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Pshufb (va_op_xmm_xmm 11) (va_op_xmm_xmm 9)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 506 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_blocks128 alg in128_b out128_b key round_keys keys_b hkeys_b h_LE) (fun
(va_s:va_state) _ -> let (y_cipher128:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s) in let (va_arg134:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b in let
(va_arg133:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg132:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 508 column 36 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_ghash_incremental0_append h_LE va_arg132 y_cipher128x6
y_cipher128 va_arg133 va_arg134) (let auth_in = FStar.Seq.Base.append #quad32 auth_in
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 22 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Stack_lemma (va_op_reg64_reg64 rRsp) (offset + 24) Public) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 512 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Add64 (va_op_dst_opr64_reg64 rR14) (va_opr_code_Stack (va_op_reg64_reg64 rRsp)
(offset + 24) Public)) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 513 column 11 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_IMul64 (va_op_dst_opr64_reg64 rR14) (va_const_opr64 16)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 514 column 17 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rR13) (va_op_reg_opr64_reg64 rRsp) (offset + 64))
(fun (va_s:va_state) _ -> let (y_inout:Vale.Def.Types_s.quad32) = y_cipher128 in let
(plain_byte_seq:(seq quad32)) = empty_seq_quad32 in let (cipher_byte_seq:(seq quad32)) =
empty_seq_quad32 in let (va_arg131:Vale.Def.Types_s.quad32) = va_get_xmm 11 va_s in let
(va_arg130:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg129:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg128:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg127:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 519 column 29 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.gctr_partial_opaque_init va_arg127 va_arg128 va_arg129 va_arg130
va_arg131) (let (total_bytes:(va_int_at_least 0)) = FStar.Seq.Base.length #quad32 auth_quad_seq
`op_Multiply` 16 + plain_num_bytes in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 523 column 8 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_qIf va_mods (Cmp_gt (va_op_cmp_reg64 rR13) (va_op_cmp_reg64 rR14)) (qblock va_mods (fun
(va_s:va_state) -> va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 525 column 21 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load64_stack (va_op_dst_opr64_reg64 rRax) (va_op_reg_opr64_reg64 rRsp) (offset + 56))
(va_QBind va_range1
"***** PRECONDITION NOT MET AT line 526 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR10) (va_op_opr64_reg64 rR13)) (fun (va_s:va_state) _
-> va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 527 column 26 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Poly1305.Math.lemma_poly_bits64 ()) (va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 528 column 14 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_And64 (va_op_dst_opr64_reg64 rR10) (va_const_opr64 15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 532 column 24 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_extra_bytes alg inout_b key round_keys keys_b hkeys_b total_bytes y_0 auth_in
h_LE) (fun (va_s:va_state) _ -> let y_inout = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm
8 va_s) in let (raw_auth_quads:(FStar.Seq.Base.seq quad32)) = FStar.Seq.Base.append #quad32
auth_in (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b) in va_qAssertSquash
va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 536 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun a_1906 (s_1907:(FStar.Seq.Base.seq a_1906)) (i_1908:Prims.nat) (j_1909:Prims.nat) -> let
(j_1869:Prims.nat) = j_1909 in Prims.b2t (Prims.op_AmpAmp (Prims.op_LessThanOrEqual i_1908
j_1869) (Prims.op_LessThanOrEqual j_1869 (FStar.Seq.Base.length #a_1906 s_1907))))
Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 total_bytes)
(fun _ -> let (auth_input_bytes:(FStar.Seq.Base.seq Vale.Def.Types_s.nat8)) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes
raw_auth_quads) 0 total_bytes in let (padded_auth_bytes:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let auth_in =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let plain_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_old_s) inout_b in let cipher_byte_seq =
Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s) inout_b in va_QEmpty ((auth_in,
cipher_byte_seq, plain_byte_seq, y_inout)))))))))) (qblock va_mods (fun (va_s:va_state) ->
va_QEmpty ((auth_in, cipher_byte_seq, plain_byte_seq, y_inout))))) (fun (va_s:va_state) va_g ->
let ((auth_in:(seq quad32)), (cipher_byte_seq:(seq quad32)), (plain_byte_seq:(seq quad32)),
(y_inout:Vale.Def.Types_s.quad32)) = va_g in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 547 column 10 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Mov64 (va_op_dst_opr64_reg64 rR11) (va_op_opr64_reg64 rR15)) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 548 column 25 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gcm_make_length_quad ()) (fun (va_s:va_state) _ -> let
(length_quad32:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 0
va_s) in va_QBind va_range1
"***** PRECONDITION NOT MET AT line 551 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Ghash_register hkeys_b h_LE y_inout) (fun (va_s:va_state) _ -> let
(y_final:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s)
in va_QSeq va_range1
"***** PRECONDITION NOT MET AT line 554 column 19 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Load128_buffer (va_op_heaplet_mem_heaplet 3) (va_op_xmm_xmm 0) (va_op_reg_opr64_reg64
rRbp) 0 Secret scratch_b 0) (va_QBind va_range1
"***** PRECONDITION NOT MET AT line 557 column 18 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_quick_Gctr_register alg key round_keys keys_b) (fun (va_s:va_state) _ -> let
(va_arg126:Vale.Def.Types_s.quad32) = va_get_xmm 8 va_s in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 560 column 40 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.Arch.Types.le_seq_quad32_to_bytes_of_singleton va_arg126)
(va_qAssertSquash va_range1
"***** EXPRESSION PRECONDITIONS NOT MET WITHIN line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
((fun (icb_BE_677:Vale.Def.Types_s.quad32) (plain_LE_678:Vale.Def.Types_s.quad32)
(alg_679:Vale.AES.AES_common_s.algorithm) (key_680:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32))
(i_681:Prims.int) -> Vale.AES.AES_s.is_aes_key_LE alg_679 key_680) j0 y_final alg key 0) (fun _
-> va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 561 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_s == Vale.AES.GCTR_s.gctr_encrypt_block j0 y_final alg key 0) (let
(plain128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let
(cipher128:(FStar.Seq.Base.seq Vale.X64.Decls.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) in128_b) in va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 566 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 plain_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 plain128 plain_byte_seq)
plain128) (va_qAssert va_range1
"***** PRECONDITION NOT MET AT line 567 column 5 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(FStar.Seq.Base.length #quad32 cipher_byte_seq == 0 ==> FStar.Seq.Base.equal
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 cipher128 cipher_byte_seq)
cipher128) (let (va_arg125:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite ctr_BE_2 len128x6
in let (va_arg124:Vale.Def.Types_s.quad32) = ctr_BE_2 in let (va_arg123:(FStar.Seq.Base.seq
Vale.Def.Types_s.nat32)) = key in let (va_arg122:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32))
= Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b in let
(va_arg121:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_old_s) in128_b in let (va_arg120:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b in let
(va_arg119:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_old_s) in128x6_b in let (va_arg118:Prims.nat) = len128 in let
(va_arg117:Prims.nat) = len128x6 in let (va_arg116:Vale.AES.AES_common_s.algorithm) = alg in
va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 569 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg116 va_arg117 va_arg118
va_arg119 va_arg120 va_arg121 va_arg122 va_arg123 va_arg124 va_arg125) (let
(va_arg115:Vale.Def.Types_s.quad32) = Vale.AES.GCTR.inc32lite (Vale.AES.GCTR.inc32lite ctr_BE_2
len128x6) len128 in let (va_arg114:Vale.Def.Types_s.quad32) = ctr_BE_2 in let
(va_arg113:(FStar.Seq.Base.seq Vale.Def.Types_s.nat32)) = key in let
(va_arg112:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = cipher_byte_seq in let
(va_arg111:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = plain_byte_seq in let
(va_arg110:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s) out128_b) in let
(va_arg109:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_old_s) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_old_s) in128_b) in let (va_arg108:Prims.nat) =
FStar.Seq.Base.length #quad32 plain_byte_seq in let (va_arg107:Prims.nat) = len128x6 + len128
in let (va_arg106:Vale.AES.AES_common_s.algorithm) = alg in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 575 column 30 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GCTR.lemma_gctr_partial_append va_arg106 va_arg107 va_arg108
va_arg109 va_arg110 va_arg111 va_arg112 va_arg113 va_arg114 va_arg115) (let
(va_arg105:(FStar.Seq.Base.seq Vale.Def.Types_s.quad32)) = auth_in in let
(va_arg104:Vale.Def.Types_s.quad32) = y_0 in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 583 column 23 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.lemma_hash_append2 h_LE va_arg104 y_inout y_final va_arg105
length_quad32) (let auth_in = FStar.Seq.Base.append #quad32 auth_in (FStar.Seq.Base.create
#Vale.Def.Types_s.quad32 1 length_quad32) in let (va_arg103:(FStar.Seq.Base.seq
Vale.Def.Types_s.quad32)) = auth_in in va_qPURE va_range1
"***** PRECONDITION NOT MET AT line 585 column 31 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(fun (_:unit) -> Vale.AES.GHash.ghash_incremental_to_ghash h_LE va_arg103) (va_QEmpty
(()))))))))))))))))))))))))))))))))))))))))))))))))
val va_lemma_Gcm_blocks : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> offset:int ->
auth_b:buffer128 -> abytes_b:buffer128 -> in128x6_b:buffer128 -> out128x6_b:buffer128 ->
in128_b:buffer128 -> out128_b:buffer128 -> inout_b:buffer128 -> iv_b:buffer128 ->
scratch_b:buffer128 -> key:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 ->
hkeys_b:buffer128
-> Ghost (va_state & va_fuel)
(requires (va_require_total va_b0 (va_code_Gcm_blocks alg offset) va_s0 /\ va_get_ok va_s0 /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp
va_s0 + offset + 8) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 24) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 40) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64
rRsp va_s0 + offset + 56) (va_get_stack va_s0) Public (va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack
va_s0) Public (va_get_stackTaint va_s0) /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet
1 va_s0) (va_get_reg64 rRdi va_s0) auth_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0)
Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0) abytes_ptr abytes_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2
va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) in128x6_ptr in128x6_b len128x6
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6
va_s0) out128x6_ptr out128x6_b len128x6 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0) in128_ptr in128_b len128
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1
va_s0) out128_ptr out128_b len128 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0) inout_ptr inout_b 1
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3
va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0) hkeys_b 8
(va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.buffer_disjoints128 iv_b ([keys_b;
scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b ([keys_b; in128x6_b; out128x6_b; in128_b;
out128_b; inout_b; hkeys_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b;
hkeys_b; in128_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b;
out128x6_b; inout_b]) /\ Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b;
out128x6_b; out128_b]) /\ (Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b
== out128x6_b) /\ (Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b)
/\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ in128x6_ptr
+ 16 `op_Multiply` len128x6 < pow2_64 /\ out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64
/\ inout_ptr + 16 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b ==
va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1
/\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == Vale.X64.Decls.buffer_length
#Vale.X64.Memory.vuint128 out128_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128
in128x6_b == len128x6 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
len128 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\
plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 <
pow2_64 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0
va_s0) + 128 < pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\ (va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128
(128 `op_Division` 8) <= plain_num_bytes /\ plain_num_bytes < va_mul_nat len128x6 (128
`op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) + 128 `op_Division` 8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 < va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128
`op_Division` 8) /\ aes_reqs alg key round_keys keys_b (va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0))))))
(ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\
(let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 0) (va_get_stack va_s0) in let (in128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0) in
let (out128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 16) (va_get_stack va_s0) in let (len128x6:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0) in
let (in128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 32) (va_get_stack va_s0) in let (out128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0) in
let (len128:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 48) (va_get_stack va_s0) in let (inout_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0) in
let (plain_num_bytes:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp
va_s0 + offset + 64) (va_get_stack va_s0) in let (h_LE:Vale.Def.Types_s.quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b 2
(va_get_mem_heaplet 0 va_s0)) in Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet
1 va_s0) (va_get_mem_heaplet 1 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer128
scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM) /\ Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\ va_get_reg64 rRsi va_s0 < pow2_32
/\ (let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in let
(ctr_BE_1:quad32) = iv_BE in let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in let
(plain_in:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b) else FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in let (cipher_out:(seq quad32)) = (if (plain_num_bytes
> (len128x6 + len128) `op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128
(va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM)
out128_b)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b) else
FStar.Seq.Base.append #Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM)
out128x6_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) in let
(cipher_bound:nat) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128 `op_Division`
8) then (len128x6 + len128 + 1) else (len128x6 + len128)) in Vale.AES.GCTR.gctr_partial alg
cipher_bound plain_in cipher_out key ctr_BE_2 /\ (let (length_quad:quad32) =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) (8
`op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply` plain_num_bytes) 0) in let
(raw_auth_quads:(seq quad32)) = (if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) then FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b) else Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0)
auth_b) in let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in let
(padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in let
(auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes in let
(raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in let (total_bytes:nat) =
FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 + plain_num_bytes in let
(raw_quad_seq:(seq quad32)) = (if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) then (let (ab:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32 raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let (pb:(seq
nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32 pb) else
raw_quad_seq) in let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq) alg
key 0))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 6 va_sM
(va_update_mem_heaplet 5 va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM
(va_update_mem_heaplet 1 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm
13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm
9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5
va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1
va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR15 va_sM (va_update_reg64 rR14 va_sM
(va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM
(va_update_reg64 rR10 va_sM (va_update_reg64 rR9 va_sM (va_update_reg64 rR8 va_sM
(va_update_reg64 rRbp va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM
(va_update_reg64 rRdx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRbx va_sM
(va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM
va_s0)))))))))))))))))))))))))))))))))))))))))
[@"opaque_to_smt"]
let va_lemma_Gcm_blocks va_b0 va_s0 alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b =
let (va_mods:va_mods_t) = [va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5;
va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14;
va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8;
va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm
1; va_Mod_xmm 0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12;
va_Mod_reg64 rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp;
va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx;
va_Mod_reg64 rRax; va_Mod_ok; va_Mod_mem] in
let va_qc = va_qcode_Gcm_blocks va_mods alg offset auth_b abytes_b in128x6_b out128x6_b in128_b
out128_b inout_b iv_b scratch_b key round_keys keys_b hkeys_b in
let (va_sM, va_fM, va_g) = va_wp_sound_code_norm (va_code_Gcm_blocks alg offset) va_qc va_s0 (fun
va_s0 va_sM va_g -> let () = va_g in label va_range1
"***** POSTCONDITION NOT MET AT line 283 column 1 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_ok va_sM) /\ (let (abytes_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64
(va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0) in let
(in128x6_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 8) (va_get_stack va_s0) in let (out128x6_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0) in
let (len128x6:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 +
offset + 24) (va_get_stack va_s0) in let (in128_ptr:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0) in
let (out128_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 40) (va_get_stack va_s0) in let (len128:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0) in
let (inout_ptr:Vale.X64.Memory.nat64) = Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0
+ offset + 56) (va_get_stack va_s0) in let (plain_num_bytes:Vale.X64.Memory.nat64) =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0) in
let (h_LE:Vale.Def.Types_s.quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.X64.Decls.buffer128_read hkeys_b 2 (va_get_mem_heaplet 0 va_s0)) in label va_range1
"***** POSTCONDITION NOT MET AT line 396 column 56 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128_b (va_get_mem_heaplet 1 va_s0) (va_get_mem_heaplet 1
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 397 column 52 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 398 column 57 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 399 column 55 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 inout_b (va_get_mem_heaplet 5 va_s0) (va_get_mem_heaplet 5
va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 400 column 58 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.X64.Decls.modifies_buffer128 out128x6_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet
6 va_sM)) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 403 column 39 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(plain_num_bytes < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 404 column 38 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_reg64 rRsi va_s0 < pow2_32) /\ label va_range1
"***** POSTCONDITION NOT MET AT line 406 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 408 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_1:quad32) = iv_BE in label va_range1
"***** POSTCONDITION NOT MET AT line 409 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (ctr_BE_2:quad32) = Vale.AES.GCTR_s.inc32 iv_BE 1 in label va_range1
"***** POSTCONDITION NOT MET AT line 412 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (plain_in:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_s0) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_s0) in128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 421 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_out:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32 (FStar.Seq.Base.append
#Vale.X64.Decls.quad32 (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b)) (Vale.X64.Decls.s128
(va_get_mem_heaplet 5 va_sM) inout_b)) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 1 va_sM) out128_b)) in label va_range1
"***** POSTCONDITION NOT MET AT line 430 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (cipher_bound:nat) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply` 128
`op_Division` 8) (fun _ -> len128x6 + len128 + 1) (fun _ -> len128x6 + len128) in label
va_range1
"***** POSTCONDITION NOT MET AT line 434 column 77 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2) /\ label
va_range1
"***** POSTCONDITION NOT MET AT line 438 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (length_quad:quad32) = Vale.Def.Types_s.reverse_bytes_quad32
(Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Words_s.Mkfour
#Vale.Def.Types_s.nat32 0 0 0 0) (8 `op_Multiply` va_get_reg64 rRsi va_s0) 1) (8 `op_Multiply`
plain_num_bytes) 0) in label va_range1
"***** POSTCONDITION NOT MET AT line 440 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_auth_quads:(seq quad32)) = va_if (va_get_reg64 rRsi va_s0 > va_get_reg64 rRdx va_s0
`op_Multiply` 128 `op_Division` 8) (fun _ -> FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b) (Vale.X64.Decls.s128
(va_get_mem_heaplet 7 va_s0) abytes_b)) (fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1
va_s0) auth_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 444 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_input_bytes:(seq nat8)) = FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads) 0 (va_get_reg64 rRsi va_s0) in label
va_range1
"***** POSTCONDITION NOT MET AT line 445 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (padded_auth_bytes:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in label
va_range1
"***** POSTCONDITION NOT MET AT line 446 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in label va_range1
"***** POSTCONDITION NOT MET AT line 448 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 (FStar.Seq.Base.append #quad32
auth_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b) in label va_range1
"***** POSTCONDITION NOT MET AT line 452 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (total_bytes:nat) = FStar.Seq.Base.length #quad32 auth_quad_seq `op_Multiply` 16 +
plain_num_bytes in label va_range1
"***** POSTCONDITION NOT MET AT line 453 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (raw_quad_seq:(seq quad32)) = va_if (plain_num_bytes > (len128x6 + len128) `op_Multiply`
128 `op_Division` 8) (fun _ -> let (ab:(seq nat8)) = FStar.Seq.Base.slice
#Vale.Def.Types_s.nat8 (Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq (Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))) 0 total_bytes in let
(pb:(seq nat8)) = Vale.AES.GCTR_s.pad_to_128_bits ab in Vale.Def.Types_s.le_bytes_to_seq_quad32
pb) (fun _ -> raw_quad_seq) in label va_range1
"***** POSTCONDITION NOT MET AT line 460 column 9 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(let (auth_quad_seq:(seq quad32)) = FStar.Seq.Base.append #quad32 raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad) in label va_range1
"***** POSTCONDITION NOT MET AT line 461 column 106 of file /home/gebner/fstar_dataset/projects/hacl-star/vale/code/crypto/aes/x64/Vale.AES.X64.GCMdecryptOpt.vaf *****"
(va_get_xmm 8 va_sM == Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1 (Vale.AES.GHash_s.ghash_LE
h_LE auth_quad_seq) alg key 0)))))))))))))))))) in
assert_norm (va_qc.mods == va_mods);
va_lemma_norm_mods ([va_Mod_flags; va_Mod_mem_heaplet 6; va_Mod_mem_heaplet 5; va_Mod_mem_heaplet
3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 1; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13;
va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7;
va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm
0; va_Mod_reg64 rR15; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64
rR11; va_Mod_reg64 rR10; va_Mod_reg64 rR9; va_Mod_reg64 rR8; va_Mod_reg64 rRbp; va_Mod_reg64
rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRdx; va_Mod_reg64 rRcx; va_Mod_reg64 rRbx; va_Mod_reg64
rRax; va_Mod_ok; va_Mod_mem]) va_sM va_s0;
(va_sM, va_fM) | {
"checked_file": "/",
"dependencies": [
"Vale.X64.State.fsti.checked",
"Vale.X64.Stack_i.fsti.checked",
"Vale.X64.Stack.fsti.checked",
"Vale.X64.QuickCodes.fsti.checked",
"Vale.X64.QuickCode.fst.checked",
"Vale.X64.Memory.fsti.checked",
"Vale.X64.Machine_s.fst.checked",
"Vale.X64.InsVector.fsti.checked",
"Vale.X64.InsStack.fsti.checked",
"Vale.X64.InsMem.fsti.checked",
"Vale.X64.InsBasic.fsti.checked",
"Vale.X64.InsAes.fsti.checked",
"Vale.X64.Flags.fsti.checked",
"Vale.X64.Decls.fsti.checked",
"Vale.X64.CPU_Features_s.fst.checked",
"Vale.Poly1305.Math.fsti.checked",
"Vale.Math.Poly2.Bits_s.fsti.checked",
"Vale.Lib.Meta.fsti.checked",
"Vale.Lib.Basic.fsti.checked",
"Vale.Def.Words_s.fsti.checked",
"Vale.Def.Words.Seq_s.fsti.checked",
"Vale.Def.Types_s.fst.checked",
"Vale.Def.Prop_s.fst.checked",
"Vale.Def.Opaque_s.fsti.checked",
"Vale.Arch.Types.fsti.checked",
"Vale.Arch.HeapImpl.fsti.checked",
"Vale.AES.X64.GHash.fsti.checked",
"Vale.AES.X64.GF128_Mul.fsti.checked",
"Vale.AES.X64.GCTR.fsti.checked",
"Vale.AES.X64.GCMencryptOpt.fsti.checked",
"Vale.AES.X64.AESopt2.fsti.checked",
"Vale.AES.X64.AESopt.fsti.checked",
"Vale.AES.X64.AESGCM.fsti.checked",
"Vale.AES.X64.AES.fsti.checked",
"Vale.AES.OptPublic.fsti.checked",
"Vale.AES.GHash_s.fst.checked",
"Vale.AES.GHash.fsti.checked",
"Vale.AES.GF128_s.fsti.checked",
"Vale.AES.GF128.fsti.checked",
"Vale.AES.GCTR_s.fst.checked",
"Vale.AES.GCTR.fsti.checked",
"Vale.AES.GCM_s.fst.checked",
"Vale.AES.GCM_helpers.fsti.checked",
"Vale.AES.GCM.fsti.checked",
"Vale.AES.AES_s.fst.checked",
"Vale.AES.AES_common_s.fst.checked",
"prims.fst.checked",
"FStar.Seq.Base.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Vale.AES.X64.GCMdecryptOpt.fst"
} | [
{
"abbrev": false,
"full_module": "Vale.Lib.Basic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"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.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.OptPublic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCMencryptOpt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Lib.Meta",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt2",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESGCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AESopt",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Math.Poly2.Bits_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.CPU_Features_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GF128_Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCodes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.QuickCode",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsAes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsMem",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.InsBasic",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Decls",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.State",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Stack_i",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Memory",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.X64.Machine_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_helpers",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Poly1305.Math",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GF128_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64.AES",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GHash_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCM",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.GCTR_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.AES_s",
"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.Words.Seq_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Words_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Seq",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Opaque_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.Def.Prop_s",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.X64",
"short_module": null
},
{
"abbrev": false,
"full_module": "Vale.AES.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": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": true,
"smtencoding_l_arith_repr": "native",
"smtencoding_nl_arith_repr": "wrapped",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [
"smt.arith.nl=false",
"smt.QI.EAGER_THRESHOLD=100",
"smt.CASE_SPLIT=3"
],
"z3refresh": false,
"z3rlimit": 1000,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
alg: Vale.AES.AES_common_s.algorithm ->
offset: Prims.int ->
auth_b: Vale.X64.Memory.buffer128 ->
abytes_b: Vale.X64.Memory.buffer128 ->
in128x6_b: Vale.X64.Memory.buffer128 ->
out128x6_b: Vale.X64.Memory.buffer128 ->
in128_b: Vale.X64.Memory.buffer128 ->
out128_b: Vale.X64.Memory.buffer128 ->
inout_b: Vale.X64.Memory.buffer128 ->
iv_b: Vale.X64.Memory.buffer128 ->
scratch_b: Vale.X64.Memory.buffer128 ->
key: FStar.Seq.Base.seq Vale.X64.Memory.nat32 ->
round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 ->
keys_b: Vale.X64.Memory.buffer128 ->
hkeys_b: Vale.X64.Memory.buffer128 ->
va_s0: Vale.X64.Decls.va_state ->
va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0)
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"Vale.AES.AES_common_s.algorithm",
"Prims.int",
"Vale.X64.Memory.buffer128",
"FStar.Seq.Base.seq",
"Vale.X64.Memory.nat32",
"Vale.X64.Decls.quad32",
"Vale.X64.Decls.va_state",
"Prims.unit",
"Prims.l_and",
"Prims.b2t",
"Vale.X64.Decls.va_get_ok",
"Vale.X64.CPU_Features_s.sse_enabled",
"Vale.X64.CPU_Features_s.movbe_enabled",
"Vale.X64.Stack_i.valid_stack_slot64",
"Prims.op_Addition",
"Vale.X64.Decls.va_get_reg64",
"Vale.X64.Machine_s.rRsp",
"Vale.X64.Decls.va_get_stack",
"Vale.Arch.HeapTypes_s.Public",
"Vale.X64.Decls.va_get_stackTaint",
"Vale.X64.Decls.validSrcAddrs128",
"Vale.X64.Decls.va_get_mem_heaplet",
"Vale.X64.Machine_s.rRdi",
"Vale.X64.Machine_s.rRdx",
"Vale.X64.Decls.va_get_mem_layout",
"Vale.Arch.HeapTypes_s.Secret",
"Vale.X64.Decls.validDstAddrs128",
"Vale.X64.Machine_s.rR8",
"Vale.X64.Machine_s.rRbp",
"Vale.X64.Machine_s.rR9",
"Vale.X64.Decls.buffer_disjoints128",
"Prims.Cons",
"Prims.Nil",
"Prims.l_or",
"Vale.X64.Decls.buffers_disjoint128",
"Prims.eq2",
"Prims.op_LessThan",
"Prims.op_Multiply",
"Vale.X64.Machine_s.pow2_64",
"Prims.nat",
"Vale.X64.Decls.buffer_length",
"Vale.X64.Memory.vuint128",
"Vale.X64.Machine_s.pow2_32",
"Vale.X64.Machine_s.rRsi",
"Vale.X64.Memory.buffer_addr",
"Prims.op_Modulus",
"Prims.l_imp",
"Prims.op_GreaterThan",
"Prims.op_GreaterThanOrEqual",
"Prims.op_LessThanOrEqual",
"Vale.X64.Decls.va_mul_nat",
"Prims.op_Division",
"Vale.AES.X64.GCMencryptOpt.aes_reqs",
"Vale.X64.Machine_s.rRcx",
"Vale.X64.CPU_Features_s.pclmulqdq_enabled",
"Vale.AES.GHash.hkeys_reqs_priv",
"Vale.X64.Decls.s128",
"Vale.Def.Types_s.reverse_bytes_quad32",
"Vale.AES.AES_s.aes_encrypt_LE",
"Vale.Def.Words_s.Mkfour",
"Vale.Def.Types_s.nat32",
"Vale.Def.Types_s.quad32",
"Vale.X64.Decls.buffer128_read",
"Vale.Def.Words_s.nat64",
"Vale.X64.Stack_i.load_stack64",
"Prims.l_Forall",
"Vale.X64.InsBasic.vale_heap",
"Vale.X64.Memory.nat64",
"Vale.X64.Flags.t",
"Vale.X64.Decls.modifies_buffer128",
"Vale.AES.GCTR.gctr_partial",
"Vale.X64.Decls.va_get_xmm",
"Vale.AES.GCTR_s.gctr_encrypt_block",
"Vale.AES.GHash_s.ghash_LE",
"FStar.Seq.Base.append",
"FStar.Seq.Base.create",
"Vale.X64.Decls.va_if",
"Vale.Def.Types_s.le_bytes_to_seq_quad32",
"Vale.Def.Words_s.nat8",
"Vale.AES.GCTR_s.pad_to_128_bits",
"FStar.Seq.Base.slice",
"Vale.Def.Types_s.nat8",
"Vale.Def.Types_s.le_seq_quad32_to_bytes",
"Prims.l_not",
"FStar.Seq.Base.length",
"Vale.Def.Types_s.insert_nat64",
"Vale.AES.GCTR_s.inc32",
"Vale.X64.State.vale_state",
"Vale.X64.Decls.va_upd_flags",
"Vale.X64.Decls.va_upd_mem_heaplet",
"Vale.X64.Decls.va_upd_xmm",
"Vale.X64.Decls.va_upd_reg64",
"Vale.X64.Machine_s.rR15",
"Vale.X64.Machine_s.rR14",
"Vale.X64.Machine_s.rR13",
"Vale.X64.Machine_s.rR12",
"Vale.X64.Machine_s.rR11",
"Vale.X64.Machine_s.rR10",
"Vale.X64.Machine_s.rRbx",
"Vale.X64.Machine_s.rRax",
"Vale.X64.Decls.va_upd_mem"
] | [] | false | false | false | true | true | let va_wp_Gcm_blocks
(alg: algorithm)
(offset: int)
(auth_b abytes_b in128x6_b out128x6_b in128_b out128_b inout_b iv_b scratch_b: buffer128)
(key: (seq nat32))
(round_keys: (seq quad32))
(keys_b hkeys_b: buffer128)
(va_s0: va_state)
(va_k: (va_state -> unit -> Type0))
: Type0 =
| (va_get_ok va_s0 /\
(let abytes_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
in
let in128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
in
let out128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0)
in
let len128x6:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0)
in
let in128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0)
in
let out128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0)
in
let len128:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0)
in
let inout_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0)
in
let plain_num_bytes:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0)
in
let h_LE:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b
2
(va_get_mem_heaplet 0 va_s0))
in
sse_enabled /\ movbe_enabled /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 0)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 8)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 16)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 24)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 32)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 40)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 48)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 56)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Stack_i.valid_stack_slot64 (va_get_reg64 rRsp va_s0 + offset + 64)
(va_get_stack va_s0)
Public
(va_get_stackTaint va_s0) /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
(va_get_reg64 rRdi va_s0)
auth_b
(va_get_reg64 rRdx va_s0)
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 7 va_s0)
abytes_ptr
abytes_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0)
(va_get_reg64 rR8 va_s0)
iv_b
1
(va_get_mem_layout va_s0)
Public /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0)
in128x6_ptr
in128x6_b
len128x6
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0)
out128x6_ptr
out128x6_b
len128x6
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 1 va_s0)
in128_ptr
in128_b
len128
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 1 va_s0)
out128_ptr
out128_b
len128
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 5 va_s0)
inout_ptr
inout_b
1
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0)
(va_get_reg64 rRbp va_s0)
scratch_b
9
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0)
(va_get_reg64 rR9 va_s0)
hkeys_b
8
(va_get_mem_layout va_s0)
Secret /\
Vale.X64.Decls.buffer_disjoints128 iv_b
([keys_b; scratch_b; in128x6_b; out128x6_b; hkeys_b; in128_b; out128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 scratch_b
([keys_b; in128x6_b; out128x6_b; in128_b; out128_b; inout_b; hkeys_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128x6_b ([keys_b; hkeys_b; in128_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 out128_b ([keys_b; hkeys_b; out128x6_b; inout_b]) /\
Vale.X64.Decls.buffer_disjoints128 inout_b ([keys_b; hkeys_b; out128x6_b; out128_b]) /\
(Vale.X64.Decls.buffers_disjoint128 in128x6_b out128x6_b \/ in128x6_b == out128x6_b) /\
(Vale.X64.Decls.buffers_disjoint128 in128_b out128_b \/ in128_b == out128_b) /\
va_get_reg64 rRdi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\
in128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
out128x6_ptr + 16 `op_Multiply` len128x6 < pow2_64 /\
in128_ptr + 16 `op_Multiply` len128 < pow2_64 /\ out128_ptr + 16 `op_Multiply` len128 < pow2_64 /\
inout_ptr + 16 < pow2_64 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 auth_b == va_get_reg64 rRdx va_s0 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 abytes_b == 1 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128x6_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b ==
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out128_b /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128x6_b == len128x6 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in128_b == len128 /\
Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 inout_b == 1 /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\ va_get_reg64 rR9 va_s0 + 32 < pow2_64 /\
Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 <
pow2_64 /\ len128x6 `op_Modulus` 6 == 0 /\ (len128x6 > 0 ==> len128x6 >= 6) /\
12 + len128x6 + 6 < pow2_32 /\
(va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) <=
plain_num_bytes /\
plain_num_bytes <
va_mul_nat len128x6 (128 `op_Division` 8) + va_mul_nat len128 (128 `op_Division` 8) +
128
`op_Division`
8) /\
(va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) <= va_get_reg64 rRsi va_s0 /\
va_get_reg64 rRsi va_s0 <
va_mul_nat (va_get_reg64 rRdx va_s0) (128 `op_Division` 8) + 128 `op_Division` 8) /\
aes_reqs alg
key
round_keys
keys_b
(va_get_reg64 rRcx va_s0)
(va_get_mem_heaplet 0 va_s0)
(va_get_mem_layout va_s0) /\ pclmulqdq_enabled /\
Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b)
(Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.AES_s.aes_encrypt_LE alg
key
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)))) /\
(forall (va_x_mem: vale_heap) (va_x_rax: nat64) (va_x_rbx: nat64) (va_x_rcx: nat64)
(va_x_rdx: nat64) (va_x_rdi: nat64) (va_x_rsi: nat64) (va_x_rbp: nat64) (va_x_r8: nat64)
(va_x_r9: nat64) (va_x_r10: nat64) (va_x_r11: nat64) (va_x_r12: nat64) (va_x_r13: nat64)
(va_x_r14: nat64) (va_x_r15: nat64) (va_x_xmm0: quad32) (va_x_xmm1: quad32)
(va_x_xmm2: quad32) (va_x_xmm3: quad32) (va_x_xmm4: quad32) (va_x_xmm5: quad32)
(va_x_xmm6: quad32) (va_x_xmm7: quad32) (va_x_xmm8: quad32) (va_x_xmm9: quad32)
(va_x_xmm10: quad32) (va_x_xmm11: quad32) (va_x_xmm12: quad32) (va_x_xmm13: quad32)
(va_x_xmm14: quad32) (va_x_xmm15: quad32) (va_x_heap1: vale_heap) (va_x_heap2: vale_heap)
(va_x_heap3: vale_heap) (va_x_heap5: vale_heap) (va_x_heap6: vale_heap)
(va_x_efl: Vale.X64.Flags.t).
let va_sM =
va_upd_flags va_x_efl
(va_upd_mem_heaplet 6
va_x_heap6
(va_upd_mem_heaplet 5
va_x_heap5
(va_upd_mem_heaplet 3
va_x_heap3
(va_upd_mem_heaplet 2
va_x_heap2
(va_upd_mem_heaplet 1
va_x_heap1
(va_upd_xmm 15
va_x_xmm15
(va_upd_xmm 14
va_x_xmm14
(va_upd_xmm 13
va_x_xmm13
(va_upd_xmm 12
va_x_xmm12
(va_upd_xmm 11
va_x_xmm11
(va_upd_xmm 10
va_x_xmm10
(va_upd_xmm 9
va_x_xmm9
(va_upd_xmm 8
va_x_xmm8
(va_upd_xmm 7
va_x_xmm7
(va_upd_xmm 6
va_x_xmm6
(va_upd_xmm 5
va_x_xmm5
(va_upd_xmm 4
va_x_xmm4
(va_upd_xmm 3
va_x_xmm3
(va_upd_xmm 2
va_x_xmm2
(va_upd_xmm 1
va_x_xmm1
(va_upd_xmm
0
va_x_xmm0
(va_upd_reg64
rR15
va_x_r15
(va_upd_reg64
rR14
va_x_r14
(
va_upd_reg64
rR13
va_x_r13
(
va_upd_reg64
rR12
va_x_r12
(
va_upd_reg64
rR11
va_x_r11
(
va_upd_reg64
rR10
va_x_r10
(
va_upd_reg64
rR9
va_x_r9
(
va_upd_reg64
rR8
va_x_r8
(
va_upd_reg64
rRbp
va_x_rbp
(
va_upd_reg64
rRsi
va_x_rsi
(
va_upd_reg64
rRdi
va_x_rdi
(
va_upd_reg64
rRdx
va_x_rdx
(
va_upd_reg64
rRcx
va_x_rcx
(
va_upd_reg64
rRbx
va_x_rbx
(
va_upd_reg64
rRax
va_x_rax
(
va_upd_mem
va_x_mem
va_s0
)
)
)
)
)
)
)
)
)
)
)
)
)
)
))
))))))))))
)))))))))))
in
va_get_ok va_sM /\
(let abytes_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 0) (va_get_stack va_s0)
in
let in128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 8) (va_get_stack va_s0)
in
let out128x6_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 16) (va_get_stack va_s0)
in
let len128x6:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 24) (va_get_stack va_s0)
in
let in128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 32) (va_get_stack va_s0)
in
let out128_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 40) (va_get_stack va_s0)
in
let len128:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 48) (va_get_stack va_s0)
in
let inout_ptr:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 56) (va_get_stack va_s0)
in
let plain_num_bytes:Vale.X64.Memory.nat64 =
Vale.X64.Stack_i.load_stack64 (va_get_reg64 rRsp va_s0 + offset + 64) (va_get_stack va_s0)
in
let h_LE:Vale.Def.Types_s.quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.X64.Decls.buffer128_read hkeys_b
2
(va_get_mem_heaplet 0 va_s0))
in
Vale.X64.Decls.modifies_buffer128 out128_b
(va_get_mem_heaplet 1 va_s0)
(va_get_mem_heaplet 1 va_sM) /\
Vale.X64.Decls.modifies_buffer128 iv_b
(va_get_mem_heaplet 2 va_s0)
(va_get_mem_heaplet 2 va_sM) /\
Vale.X64.Decls.modifies_buffer128 scratch_b
(va_get_mem_heaplet 3 va_s0)
(va_get_mem_heaplet 3 va_sM) /\
Vale.X64.Decls.modifies_buffer128 inout_b
(va_get_mem_heaplet 5 va_s0)
(va_get_mem_heaplet 5 va_sM) /\
Vale.X64.Decls.modifies_buffer128 out128x6_b
(va_get_mem_heaplet 6 va_s0)
(va_get_mem_heaplet 6 va_sM) /\ plain_num_bytes < pow2_32 /\
va_get_reg64 rRsi va_s0 < pow2_32 /\
(let iv_BE = Vale.X64.Decls.buffer128_read iv_b 0 (va_get_mem_heaplet 2 va_s0) in
let ctr_BE_1:quad32 = iv_BE in
let ctr_BE_2:quad32 = Vale.AES.GCTR_s.inc32 iv_BE 1 in
let plain_in:(seq quad32) =
va_if (plain_num_bytes > ((len128x6 + len128) `op_Multiply` 128) `op_Division` 8)
(fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b))
(fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b))
in
let cipher_out:(seq quad32) =
va_if (plain_num_bytes > ((len128x6 + len128) `op_Multiply` 128) `op_Division` 8)
(fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_sM) inout_b))
(fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out128x6_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_sM) out128_b))
in
let cipher_bound:nat =
va_if (plain_num_bytes > ((len128x6 + len128) `op_Multiply` 128) `op_Division` 8)
(fun _ -> len128x6 + len128 + 1)
(fun _ -> len128x6 + len128)
in
Vale.AES.GCTR.gctr_partial alg cipher_bound plain_in cipher_out key ctr_BE_2 /\
(let length_quad:quad32 =
Vale.Def.Types_s.reverse_bytes_quad32 (Vale.Def.Types_s.insert_nat64 (Vale.Def.Types_s.insert_nat64
(Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0)
(8 `op_Multiply` (va_get_reg64 rRsi va_s0))
1)
(8 `op_Multiply` plain_num_bytes)
0)
in
let raw_auth_quads:(seq quad32) =
va_if (va_get_reg64 rRsi va_s0 >
((va_get_reg64 rRdx va_s0) `op_Multiply` 128)
`op_Division`
8)
(fun _ ->
FStar.Seq.Base.append #Vale.X64.Decls.quad32
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
(Vale.X64.Decls.s128 (va_get_mem_heaplet 7 va_s0) abytes_b))
(fun _ -> Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) auth_b)
in
let auth_input_bytes:(seq nat8) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes raw_auth_quads)
0
(va_get_reg64 rRsi va_s0)
in
let padded_auth_bytes:(seq nat8) = Vale.AES.GCTR_s.pad_to_128_bits auth_input_bytes in
let auth_quad_seq:(seq quad32) =
Vale.Def.Types_s.le_bytes_to_seq_quad32 padded_auth_bytes
in
let raw_quad_seq:(seq quad32) =
FStar.Seq.Base.append #quad32
(FStar.Seq.Base.append #quad32
auth_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in128x6_b))
(Vale.X64.Decls.s128 (va_get_mem_heaplet 1 va_s0) in128_b)
in
let total_bytes:nat =
(FStar.Seq.Base.length #quad32 auth_quad_seq) `op_Multiply` 16 + plain_num_bytes
in
let raw_quad_seq:(seq quad32) =
va_if (plain_num_bytes > ((len128x6 + len128) `op_Multiply` 128) `op_Division` 8)
(fun _ ->
let ab:(seq nat8) =
FStar.Seq.Base.slice #Vale.Def.Types_s.nat8
(Vale.Def.Types_s.le_seq_quad32_to_bytes (FStar.Seq.Base.append #quad32
raw_quad_seq
(Vale.X64.Decls.s128 (va_get_mem_heaplet 5 va_s0) inout_b)))
0
total_bytes
in
let pb:(seq nat8) = Vale.AES.GCTR_s.pad_to_128_bits ab in
Vale.Def.Types_s.le_bytes_to_seq_quad32 pb)
(fun _ -> raw_quad_seq)
in
let auth_quad_seq:(seq quad32) =
FStar.Seq.Base.append #quad32
raw_quad_seq
(FStar.Seq.Base.create #quad32 1 length_quad)
in
va_get_xmm 8 va_sM ==
Vale.AES.GCTR_s.gctr_encrypt_block ctr_BE_1
(Vale.AES.GHash_s.ghash_LE h_LE auth_quad_seq)
alg
key
0))) ==>
va_k va_sM (()))) | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_from_bytes_le | val vecs_from_bytes_le: vt:v_inttype -> w:width -> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w)) -> lseq (vec_t vt w) len | val vecs_from_bytes_le: vt:v_inttype -> w:width -> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w)) -> lseq (vec_t vt w) len | let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b) | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 52,
"end_line": 19,
"start_col": 0,
"start_line": 18
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
vt: Lib.IntVector.v_inttype ->
w: Lib.IntVector.width ->
len: Prims.nat{len * (Lib.IntTypes.numbytes vt * w) <= Lib.IntTypes.max_size_t} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 (len * (Lib.IntTypes.numbytes vt * w))
-> Lib.Sequence.lseq (Lib.IntVector.vec_t vt w) len | Prims.Tot | [
"total"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Lib.Sequence.createi",
"Lib.IntVector.vec_t",
"Lib.IntVector.Serialize.vecs_from_bytes_le_f"
] | [] | false | false | false | false | false | let vecs_from_bytes_le vt w len b =
| LSeq.createi len (vecs_from_bytes_le_f vt w len b) | false |
Hacl.Frodo.KEM.fst | Hacl.Frodo.KEM.crypto_kem_keypair | val crypto_kem_keypair: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_keypair_st a gen_a | val crypto_kem_keypair: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_keypair_st a gen_a | let crypto_kem_keypair a gen_a pk sk =
Hacl.Impl.Frodo.KEM.KeyGen.crypto_kem_keypair a gen_a pk sk | {
"file_name": "code/frodo/Hacl.Frodo.KEM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 61,
"end_line": 34,
"start_col": 0,
"start_line": 33
} | module Hacl.Frodo.KEM
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Frodo.Random
module S = Spec.Frodo.KEM
module FP = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let crypto_kem_keypair_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
pk:lbytes (crypto_publickeybytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h pk /\ live h sk /\
disjoint pk sk /\ disjoint state pk /\ disjoint state sk)
(ensures fun h0 r h1 -> modifies (loc state |+| (loc pk |+| loc sk)) h0 h1 /\
(as_seq h1 pk, as_seq h1 sk) == S.crypto_kem_keypair a gen_a (as_seq h0 state))
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.Decaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Frodo.KEM.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"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": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a}
-> Hacl.Frodo.KEM.crypto_kem_keypair_st a gen_a | Prims.Tot | [
"total"
] | [] | [
"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.crypto_publickeybytes",
"Hacl.Impl.Frodo.Params.crypto_secretkeybytes",
"Hacl.Impl.Frodo.KEM.KeyGen.crypto_kem_keypair",
"Lib.IntTypes.uint32"
] | [] | false | false | false | false | false | let crypto_kem_keypair a gen_a pk sk =
| Hacl.Impl.Frodo.KEM.KeyGen.crypto_kem_keypair a gen_a pk sk | false |
Hacl.Frodo.KEM.fst | Hacl.Frodo.KEM.crypto_kem_dec | val crypto_kem_dec: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_dec_st a gen_a | val crypto_kem_dec: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_dec_st a gen_a | let crypto_kem_dec a gen_a ss ct sk =
Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec a gen_a ss ct sk | {
"file_name": "code/frodo/Hacl.Frodo.KEM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 60,
"end_line": 73,
"start_col": 0,
"start_line": 72
} | module Hacl.Frodo.KEM
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Frodo.Random
module S = Spec.Frodo.KEM
module FP = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let crypto_kem_keypair_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
pk:lbytes (crypto_publickeybytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h pk /\ live h sk /\
disjoint pk sk /\ disjoint state pk /\ disjoint state sk)
(ensures fun h0 r h1 -> modifies (loc state |+| (loc pk |+| loc sk)) h0 h1 /\
(as_seq h1 pk, as_seq h1 sk) == S.crypto_kem_keypair a gen_a (as_seq h0 state))
inline_for_extraction noextract
val crypto_kem_keypair: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_keypair_st a gen_a
let crypto_kem_keypair a gen_a pk sk =
Hacl.Impl.Frodo.KEM.KeyGen.crypto_kem_keypair a gen_a pk sk
inline_for_extraction noextract
let crypto_kem_enc_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack uint32
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint state ct /\ disjoint state ss /\ disjoint state pk)
(ensures fun h0 _ h1 -> modifies (loc state |+| (loc ct |+| loc ss)) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc a gen_a (as_seq h0 state) (as_seq h0 pk))
inline_for_extraction noextract
val crypto_kem_enc: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_enc_st a gen_a
let crypto_kem_enc a gen_a ct ss pk =
Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc a gen_a ct ss pk
inline_for_extraction noextract
let crypto_kem_dec_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\
disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk)
(ensures fun h0 r h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk))
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.Decaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Frodo.KEM.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"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": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a}
-> Hacl.Frodo.KEM.crypto_kem_dec_st a gen_a | Prims.Tot | [
"total"
] | [] | [
"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.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_secretkeybytes",
"Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec",
"Lib.IntTypes.uint32"
] | [] | false | false | false | false | false | let crypto_kem_dec a gen_a ss ct sk =
| Hacl.Impl.Frodo.KEM.Decaps.crypto_kem_dec a gen_a ss ct sk | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_from_bytes_be_f | val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w | val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w | let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w)) | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 79,
"end_line": 33,
"start_col": 0,
"start_line": 32
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
vt: Lib.IntVector.v_inttype ->
w: Lib.IntVector.width ->
len: Prims.nat{len * (Lib.IntTypes.numbytes vt * w) <= Lib.IntTypes.max_size_t} ->
b: Lib.Sequence.lseq Lib.IntTypes.uint8 (len * (Lib.IntTypes.numbytes vt * w)) ->
i: Prims.nat{i < len}
-> Lib.IntVector.vec_t vt w | Prims.Tot | [
"total"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntTypes.uint8",
"Prims.op_LessThan",
"Lib.IntVector.vec_from_bytes_be",
"Lib.Sequence.sub",
"Lib.IntVector.vec_t"
] | [] | false | false | false | false | false | let vecs_from_bytes_be_f vt w len b i =
| vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w)) | false |
Hacl.Frodo.KEM.fst | Hacl.Frodo.KEM.crypto_kem_enc | val crypto_kem_enc: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_enc_st a gen_a | val crypto_kem_enc: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_enc_st a gen_a | let crypto_kem_enc a gen_a ct ss pk =
Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc a gen_a ct ss pk | {
"file_name": "code/frodo/Hacl.Frodo.KEM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 60,
"end_line": 54,
"start_col": 0,
"start_line": 53
} | module Hacl.Frodo.KEM
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Frodo.Random
module S = Spec.Frodo.KEM
module FP = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let crypto_kem_keypair_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
pk:lbytes (crypto_publickeybytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h pk /\ live h sk /\
disjoint pk sk /\ disjoint state pk /\ disjoint state sk)
(ensures fun h0 r h1 -> modifies (loc state |+| (loc pk |+| loc sk)) h0 h1 /\
(as_seq h1 pk, as_seq h1 sk) == S.crypto_kem_keypair a gen_a (as_seq h0 state))
inline_for_extraction noextract
val crypto_kem_keypair: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_keypair_st a gen_a
let crypto_kem_keypair a gen_a pk sk =
Hacl.Impl.Frodo.KEM.KeyGen.crypto_kem_keypair a gen_a pk sk
inline_for_extraction noextract
let crypto_kem_enc_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack uint32
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint state ct /\ disjoint state ss /\ disjoint state pk)
(ensures fun h0 _ h1 -> modifies (loc state |+| (loc ct |+| loc ss)) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc a gen_a (as_seq h0 state) (as_seq h0 pk))
inline_for_extraction noextract | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.Decaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Frodo.KEM.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"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": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a}
-> Hacl.Frodo.KEM.crypto_kem_enc_st a gen_a | Prims.Tot | [
"total"
] | [] | [
"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.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc",
"Lib.IntTypes.uint32"
] | [] | false | false | false | false | false | let crypto_kem_enc a gen_a ct ss pk =
| Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc a gen_a ct ss pk | false |
LowParse.SLow.BCVLI.fst | LowParse.SLow.BCVLI.serialize32_bounded_bcvli | val serialize32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (serializer32 (serialize_bounded_bcvli min max)) | val serialize32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (serializer32 (serialize_bounded_bcvli min max)) | let serialize32_bounded_bcvli
(min: nat)
(max: nat { min <= max })
: Tot (serializer32 (serialize_bounded_bcvli min max))
= fun x -> ((
[@inline_let]
let _ = serialize_bounded_bcvli_eq min max x in
serialize32_bcvli x
) <: (res: _ { serializer32_correct (serialize_bounded_bcvli min max) x res })) | {
"file_name": "src/lowparse/LowParse.SLow.BCVLI.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 81,
"end_line": 136,
"start_col": 0,
"start_line": 128
} | module LowParse.SLow.BCVLI
include LowParse.Spec.BCVLI
include LowParse.SLow.Combinators // for make_total_constant_size_parser32
include LowParse.SLow.BoundedInt // for bounded_integer_le
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
module Cast = FStar.Int.Cast
#push-options "--max_fuel 0"
let parse32_bcvli
: parser32 parse_bcvli
= fun input -> ((
[@inline_let] let _ =
parse_bcvli_eq (B32.reveal input)
in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul
then Some (x32, consumed_x)
else
let input' = B32.slice input consumed_x (B32.len input) in
if x32 = 253ul
then
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 253ul then None else Some (y, consumed_x `U32.add` consumed_y)
else if x32 = 254ul
then
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 65536ul then None else Some (y, consumed_x `U32.add` consumed_y)
else
None
) <: (res: _ { parser32_correct parse_bcvli input res } ))
module U8 = FStar.UInt8
let serialize32_bcvli
: serializer32 serialize_bcvli
= fun x -> ((
[@inline_let] let _ = serialize_bcvli_eq x in
let c1 : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
let s1 = serialize32_bounded_integer_le_1 c1 in
if c1 `U32.lt` 253ul
then s1
else if c1 = 253ul
then s1 `B32.append` serialize32_bounded_integer_le_2 x
else s1 `B32.append` serialize32_bounded_integer_le_4 x
) <: (res: bytes32 { serializer32_correct' serialize_bcvli x res } ))
let size32_bcvli
: size32 serialize_bcvli
= fun x -> ((
[@inline_let] let _ = serialize_bcvli_eq x in
if x `U32.lt` 253ul
then 1ul
else if x `U32.lt` 65536ul
then 3ul
else 5ul
) <: (res: _ { size32_postcond serialize_bcvli x res } ))
inline_for_extraction
let parse32_bounded_bcvli
(min: nat)
(min32: U32.t { U32.v min32 == min })
(max: nat { min <= max })
(max32: U32.t { U32.v max32 == max })
: Tot (parser32 (parse_bounded_bcvli min max))
= fun input -> ((
[@inline_let]
let _ = parse_bounded_bcvli_eq min max (B32.reveal input) in
[@inline_let]
let _ = parse_bcvli_eq (B32.reveal input) in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul && min32 `U32.lte` x32 && x32 `U32.lte` max32
then Some (x32, consumed_x)
else if max32 `U32.lt` 253ul
then None
else
if x32 = 253ul
then
if 65536ul `U32.lte` min32
then None
else
let input' = B32.slice input consumed_x (B32.len input) in
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if
y `U32.lt` 253ul || y `U32.lt` min32 || max32 `U32.lt` y
then
None
else
Some (y, consumed_x `U32.add` consumed_y)
else if max32 `U32.lt` 65536ul
then None
else if x32 = 254ul
then
let input' = B32.slice input consumed_x (B32.len input) in
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if
y `U32.lt` 65536ul || y `U32.lt` min32 || max32 `U32.lt` y
then
None
else
Some (y, consumed_x `U32.add` consumed_y)
else
None
) <: (res: _ { parser32_correct (parse_bounded_bcvli min max) input res })) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.SLow.BoundedInt.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.BCVLI.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | min: Prims.nat -> max: Prims.nat{min <= max}
-> LowParse.SLow.Base.serializer32 (LowParse.Spec.BCVLI.serialize_bounded_bcvli min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.SLow.BCVLI.serialize32_bcvli",
"Prims.unit",
"LowParse.Spec.BCVLI.serialize_bounded_bcvli_eq",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bounded_bcvli",
"LowParse.Spec.BCVLI.serialize_bounded_bcvli",
"LowParse.SLow.Base.serializer32"
] | [] | false | false | false | false | false | let serialize32_bounded_bcvli (min: nat) (max: nat{min <= max})
: Tot (serializer32 (serialize_bounded_bcvli min max)) =
| fun x ->
(([@@ inline_let ]let _ = serialize_bounded_bcvli_eq min max x in
serialize32_bcvli x)
<:
(res: _{serializer32_correct (serialize_bounded_bcvli min max) x res})) | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_to_bytes_le | val vecs_to_bytes_le: #vt:v_inttype -> #w:width -> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len -> lseq uint8 (len * (numbytes vt * w)) | val vecs_to_bytes_le: #vt:v_inttype -> #w:width -> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len -> lseq uint8 (len * (numbytes vt * w)) | let vecs_to_bytes_le #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_le_f #vt #w #len vl) () in
o | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 57,
"start_col": 0,
"start_line": 53
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | vl: Lib.Sequence.lseq (Lib.IntVector.vec_t vt w) len
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (len * (Lib.IntTypes.numbytes vt * w)) | Prims.Tot | [
"total"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.eq2",
"Prims.int",
"Lib.Sequence.length",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Lib.Sequence.generate_blocks",
"Lib.IntVector.Serialize.vecs_to_bytes_le_f",
"Prims.eqtype",
"Prims.unit"
] | [] | false | false | false | false | false | let vecs_to_bytes_le #vt #w #len vl =
| let a_spec (i: nat{i <= len}) = unit in
let _, o =
generate_blocks (numbytes vt * w) len len a_spec (vecs_to_bytes_le_f #vt #w #len vl) ()
in
o | false |
Hacl.Impl.RSAPSS.fst | Hacl.Impl.RSAPSS.rsapss_sign_ | val rsapss_sign_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st1 t ke a modBits | val rsapss_sign_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st1 t ke a modBits | let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m;
let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in
pop_frame ();
eq_b | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 6,
"end_line": 224,
"start_col": 0,
"start_line": 216
} | module Hacl.Impl.RSAPSS
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module Hash = Spec.Agile.Hash
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module SD = Hacl.Spec.Bignum.Definitions
module SM = Hacl.Spec.Bignum.Montgomery
module SE = Hacl.Spec.Bignum.Exponentiation
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module S = Spec.RSAPSS
module LS = Hacl.Spec.RSAPSS
module LSeq = Lib.Sequence
module RP = Hacl.Impl.RSAPSS.Padding
module RM = Hacl.Impl.RSAPSS.MGF
module RK = Hacl.Impl.RSAPSS.Keys
#reset-options "--z3rlimit 150 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
inline_for_extraction noextract
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> m':lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h skey /\ live h m /\ live h s /\ live h m' /\
disjoint s m /\ disjoint s skey /\ disjoint m skey /\
disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\
(r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let eLen = blocks eBits (size bits) in
let dLen = blocks dBits (size bits) in
let n = sub skey 0ul nLen in
let r2 = sub skey nLen nLen in
let e = sub skey (nLen +! nLen) eLen in
let d = sub skey (nLen +! nLen +! eLen) dLen in
Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits);
let h0 = ST.get () in
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n);
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s;
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m';
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 s)
(SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h0 m) (v dBits) (as_seq h0 d));
SD.bn_eval_inj (v nLen) (as_seq h1 m')
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
let eq_m = BN.bn_eq_mask nLen m m' in
mapT nLen s (logand eq_m) s;
BB.unsafe_bool_of_limb eq_m
inline_for_extraction noextract
let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t len ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h m /\
disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\
as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_msg_to_bn:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_msg_to_bn_st t a modBits
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
RP.pss_encode a saltLen salt msgLen msg emBits em;
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits = v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let h' = ST.get () in
update_sub_f h' m 0ul mLen
(fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em))
(fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen));
pop_frame ()
inline_for_extraction noextract
let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h skey /\ live h m /\
disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_compute_sgnt:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_sign_compute_sgnt_st t ke modBits
let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt =
push_frame ();
let h_init = ST.get () in
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
let m' = create nLen (uint #t 0) in
let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_to_bytes_be k s sgnt;
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st1 t ke a modBits | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.RSAPSS.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.RSAPSS.Padding.fst.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Impl.RSAPSS.Keys.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Keys",
"short_module": "RK"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": "RM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Padding",
"short_module": "RP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.RSAPSS",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ke: Hacl.Bignum.Exponentiation.exp t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t
-> Hacl.Impl.RSAPSS.rsapss_sign_st1 t ke a modBits | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Exponentiation.exp",
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Hacl.Impl.RSAPSS.modBits_t",
"Lib.IntTypes.size_t",
"Hacl.Spec.RSAPSS.skey_len_pre",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Hacl.Bignum.Definitions.lbignum",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"FStar.UInt32.__uint_to_t",
"Hacl.Bignum.Definitions.blocks",
"Lib.IntTypes.size",
"Lib.IntTypes.bits",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Prims.bool",
"Prims.unit",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Impl.RSAPSS.rsapss_sign_compute_sgnt",
"Hacl.Impl.RSAPSS.rsapss_sign_msg_to_bn",
"Lib.Buffer.lbuffer_t",
"Lib.Buffer.MUT",
"Hacl.Bignum.Definitions.limb",
"Lib.Buffer.create",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"Lib.IntTypes.int_t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"Lib.IntTypes.range",
"Prims.l_and",
"Prims.op_GreaterThan",
"Prims.op_LessThanOrEqual",
"Prims.op_Subtraction",
"Prims.pow2",
"Prims.op_Multiply",
"Lib.IntTypes.mk_int",
"Hacl.Spec.Bignum.Definitions.blocks",
"Prims.pos",
"FStar.HyperStack.ST.push_frame"
] | [] | false | false | false | false | false | let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
| push_frame ();
[@@ inline_let ]let bits:size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m;
let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in
pop_frame ();
eq_b | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_to_bytes_le_f | val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w) | val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w) | let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i] | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 51,
"start_col": 0,
"start_line": 50
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | vl: Lib.Sequence.lseq (Lib.IntVector.vec_t vt w) len -> i: Prims.nat{i < len} -> _: Prims.unit
-> Prims.unit * Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.numbytes vt * w) | Prims.Tot | [
"total"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Prims.op_LessThan",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.uint8",
"Lib.IntVector.vec_to_bytes_le",
"Lib.Sequence.op_String_Access",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | false | false | let vecs_to_bytes_le_f #vt #w #len vl i () =
| (), vec_to_bytes_le vl.[ i ] | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_to_bytes_be_f | val vecs_to_bytes_be_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w) | val vecs_to_bytes_be_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w) | let vecs_to_bytes_be_f #vt #w #len vl i () =
(), vec_to_bytes_be vl.[i] | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 28,
"end_line": 74,
"start_col": 0,
"start_line": 73
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i]
let vecs_to_bytes_le #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_le_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_le #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_le_f #vt #w #len vl) i
val vecs_to_bytes_be_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | vl: Lib.Sequence.lseq (Lib.IntVector.vec_t vt w) len -> i: Prims.nat{i < len} -> _: Prims.unit
-> Prims.unit * Lib.Sequence.lseq Lib.IntTypes.uint8 (Lib.IntTypes.numbytes vt * w) | Prims.Tot | [
"total"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Prims.op_LessThan",
"Prims.unit",
"FStar.Pervasives.Native.Mktuple2",
"Lib.IntTypes.uint8",
"Lib.IntVector.vec_to_bytes_be",
"Lib.Sequence.op_String_Access",
"FStar.Pervasives.Native.tuple2"
] | [] | false | false | false | false | false | let vecs_to_bytes_be_f #vt #w #len vl i () =
| (), vec_to_bytes_be vl.[ i ] | false |
Hacl.Frodo.KEM.fst | Hacl.Frodo.KEM.crypto_kem_keypair_st | val crypto_kem_keypair_st : a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a}
-> Type0 | let crypto_kem_keypair_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
pk:lbytes (crypto_publickeybytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h pk /\ live h sk /\
disjoint pk sk /\ disjoint state pk /\ disjoint state sk)
(ensures fun h0 r h1 -> modifies (loc state |+| (loc pk |+| loc sk)) h0 h1 /\
(as_seq h1 pk, as_seq h1 sk) == S.crypto_kem_keypair a gen_a (as_seq h0 state)) | {
"file_name": "code/frodo/Hacl.Frodo.KEM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 85,
"end_line": 28,
"start_col": 0,
"start_line": 20
} | module Hacl.Frodo.KEM
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Frodo.Random
module S = Spec.Frodo.KEM
module FP = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.Decaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Frodo.KEM.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"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": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a}
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"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.crypto_publickeybytes",
"Hacl.Impl.Frodo.Params.crypto_secretkeybytes",
"Lib.IntTypes.uint32",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.Buffer.disjoint",
"Hacl.Frodo.Random.state",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Lib.ByteSequence.lbytes",
"Spec.Frodo.Params.crypto_publickeybytes",
"Spec.Frodo.Params.crypto_secretkeybytes",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Spec.Frodo.KEM.crypto_kem_keypair",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | true | let crypto_kem_keypair_st (a: FP.frodo_alg) (gen_a: FP.frodo_gen_a{is_supported gen_a}) =
| pk: lbytes (crypto_publickeybytes a) -> sk: lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires
fun h -> live h pk /\ live h sk /\ disjoint pk sk /\ disjoint state pk /\ disjoint state sk)
(ensures
fun h0 r h1 ->
modifies (loc state |+| (loc pk |+| loc sk)) h0 h1 /\
(as_seq h1 pk, as_seq h1 sk) == S.crypto_kem_keypair a gen_a (as_seq h0 state)) | false |
|
Hacl.Impl.RSAPSS.fst | Hacl.Impl.RSAPSS.rsapss_skey_sign | val rsapss_skey_sign:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t
-> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits
-> rsapss_sign:rsapss_sign_st t ke a modBits ->
rsapss_skey_sign_st t ke a modBits | val rsapss_skey_sign:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t
-> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits
-> rsapss_sign:rsapss_sign_st t ke a modBits ->
rsapss_skey_sign_st t ke a modBits | let rsapss_skey_sign #t ke a modBits rsapss_load_skey rsapss_sign eBits dBits nb eb db saltLen salt msgLen msg sgnt =
[@inline_let] let bits = size (bits t) in
let h0 = ST.get () in
push_frame ();
let skey = create (2ul *! blocks modBits bits +! blocks eBits bits +! blocks dBits bits) (uint #t 0) in
let b = rsapss_load_skey eBits dBits nb eb db skey in
LS.rsapss_load_skey_lemma #t (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db);
let res =
if b then
rsapss_sign eBits dBits skey saltLen salt msgLen msg sgnt
else
false in
pop_frame ();
let h1 = ST.get () in
assert ((res, as_seq h1 sgnt) == LS.rsapss_skey_sign #t a (v modBits) (v eBits) (v dBits)
(as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt)
(v msgLen) (as_seq h0 msg) (as_seq h0 sgnt));
res | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 5,
"end_line": 571,
"start_col": 0,
"start_line": 553
} | module Hacl.Impl.RSAPSS
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Bignum.Definitions
module ST = FStar.HyperStack.ST
module Hash = Spec.Agile.Hash
module SB = Hacl.Spec.Bignum
module BB = Hacl.Spec.Bignum.Base
module SD = Hacl.Spec.Bignum.Definitions
module SM = Hacl.Spec.Bignum.Montgomery
module SE = Hacl.Spec.Bignum.Exponentiation
module BN = Hacl.Bignum
module BE = Hacl.Bignum.Exponentiation
module BM = Hacl.Bignum.Montgomery
module S = Spec.RSAPSS
module LS = Hacl.Spec.RSAPSS
module LSeq = Lib.Sequence
module RP = Hacl.Impl.RSAPSS.Padding
module RM = Hacl.Impl.RSAPSS.MGF
module RK = Hacl.Impl.RSAPSS.Keys
#reset-options "--z3rlimit 150 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let modBits_t (t:limb_t) = modBits:size_t{1 < v modBits /\ 2 * bits t * SD.blocks (v modBits) (bits t) <= max_size_t}
inline_for_extraction noextract
let rsapss_sign_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> m':lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h skey /\ live h m /\ live h s /\ live h m' /\
disjoint s m /\ disjoint s skey /\ disjoint m skey /\
disjoint m m' /\ disjoint m' s /\ disjoint m' skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 r h1 -> modifies (loc s |+| loc m') h0 h1 /\
(r, as_seq h1 s) == LS.rsapss_sign_bn (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_sign_bn_st t ke modBits
let rsapss_sign_bn #t ke modBits eBits dBits skey m m' s =
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let eLen = blocks eBits (size bits) in
let dLen = blocks dBits (size bits) in
let n = sub skey 0ul nLen in
let r2 = sub skey nLen nLen in
let e = sub skey (nLen +! nLen) eLen in
let d = sub skey (nLen +! nLen +! eLen) dLen in
Math.Lemmas.pow2_le_compat (bits * v nLen) (v modBits);
let h0 = ST.get () in
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h0 n);
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_ct_precomp n r2 m dBits d s;
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m';
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 s)
(SE.bn_mod_exp_consttime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h0 m) (v dBits) (as_seq h0 d));
SD.bn_eval_inj (v nLen) (as_seq h1 m')
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
let eq_m = BN.bn_eq_mask nLen m m' in
mapT nLen s (logand eq_m) s;
BB.unsafe_bool_of_limb eq_m
inline_for_extraction noextract
let rsapss_sign_msg_to_bn_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t len ->
Stack unit
(requires fun h ->
live h salt /\ live h msg /\ live h m /\
disjoint salt msg /\ disjoint m msg /\ disjoint m salt /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 _ h1 -> modifies (loc m) h0 h1 /\
as_seq h1 m == LS.rsapss_sign_msg_to_bn a (v modBits) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_msg_to_bn:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_msg_to_bn_st t a modBits
let rsapss_sign_msg_to_bn #t a modBits saltLen salt msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
RP.pss_encode a saltLen salt msgLen msg emBits em;
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits = v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let h' = ST.get () in
update_sub_f h' m 0ul mLen
(fun h -> SB.bn_from_bytes_be (v emLen) (as_seq h' em))
(fun _ -> BN.bn_from_bytes_be emLen em (sub m 0ul mLen));
pop_frame ()
inline_for_extraction noextract
let rsapss_sign_compute_sgnt_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> m:lbignum t len
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h skey /\ live h m /\
disjoint sgnt skey /\ disjoint m sgnt /\ disjoint m skey /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
bn_v h m < bn_v h (gsub skey 0ul len))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_compute_sgnt (v modBits) (v eBits) (v dBits) (as_seq h0 skey) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_sign_compute_sgnt:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_sign_compute_sgnt_st t ke modBits
let rsapss_sign_compute_sgnt #t ke modBits eBits dBits skey m sgnt =
push_frame ();
let h_init = ST.get () in
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
let m' = create nLen (uint #t 0) in
let eq_b = rsapss_sign_bn ke modBits eBits dBits skey m m' s in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_to_bytes_be k s sgnt;
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey) /\
LS.rsapss_sign_pre a (v modBits) (v saltLen) (as_seq h salt) (v msgLen) (as_seq h msg))
(ensures fun h0 eq_m h1 -> modifies (loc sgnt) h0 h1 /\
(eq_m, as_seq h1 sgnt) == LS.rsapss_sign_ a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_sign_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st1 t ke a modBits
let rsapss_sign_ #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
rsapss_sign_msg_to_bn a modBits saltLen salt msgLen msg m;
let eq_b = rsapss_sign_compute_sgnt ke modBits eBits dBits skey m sgnt in
pop_frame ();
eq_b
inline_for_extraction noextract
let rsapss_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> skey:lbignum t (2ul *! len +! blocks eBits (size (bits t)) +! blocks dBits (size (bits t)))
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\ live h skey /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\ disjoint sgnt skey /\
disjoint salt msg /\
LS.rsapss_skey_pre (v modBits) (v eBits) (v dBits) (as_seq h skey))
(ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\
(b, as_seq h1 sgnt) == LS.rsapss_sign a (v modBits) (v eBits) (v dBits)
(as_seq h0 skey) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt))
inline_for_extraction noextract
val rsapss_sign:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_sign_st t ke a modBits
let rsapss_sign #t ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt =
let hLen = RM.hash_len a in
Math.Lemmas.pow2_lt_compat 61 32;
Math.Lemmas.pow2_lt_compat 125 32;
//assert (max_size_t < Hash.max_input_length a);
let b =
saltLen <=. 0xfffffffful -! hLen -! 8ul &&
saltLen +! hLen +! 2ul <=. blocks (modBits -! 1ul) 8ul in
if b then
rsapss_sign_ ke a modBits eBits dBits skey saltLen salt msgLen msg sgnt
else
false
inline_for_extraction noextract
val bn_lt_pow2:
#t:limb_t
-> modBits:size_t{1 < v modBits}
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h -> live h m)
(ensures fun h0 r h1 -> h0 == h1 /\
r == LS.bn_lt_pow2 (v modBits) (as_seq h0 m))
let bn_lt_pow2 #t modBits m =
if not ((modBits -! 1ul) %. 8ul =. 0ul) then true
else begin
let get_bit = BN.bn_get_ith_bit (blocks modBits (size (bits t))) m (modBits -! 1ul) in
BB.unsafe_bool_of_limb0 get_bit end
inline_for_extraction noextract
let rsapss_verify_bn_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> m_def:lbignum t len
-> s:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h pkey /\ live h m_def /\ live h s /\
disjoint m_def pkey /\ disjoint m_def s /\ disjoint s pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies (loc m_def) h0 h1 /\
(r, as_seq h1 m_def) == LS.rsapss_verify_bn (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 m_def) (as_seq h0 s))
inline_for_extraction noextract
val rsapss_verify_bn: #t:limb_t -> ke:BE.exp t -> modBits:modBits_t t -> rsapss_verify_bn_st t ke modBits
let rsapss_verify_bn #t ke modBits eBits pkey m_def s =
[@inline_let] let bits = size (bits t) in
let nLen = blocks modBits bits in
let eLen = blocks eBits bits in
let n = sub pkey 0ul nLen in
let r2 = sub pkey nLen nLen in
let e = sub pkey (nLen +! nLen) eLen in
let mask = BN.bn_lt_mask nLen s n in
let h = ST.get () in
SB.bn_lt_mask_lemma (as_seq h s) (as_seq h n);
let res =
if BB.unsafe_bool_of_limb mask then begin
Math.Lemmas.pow2_le_compat (v bits * v nLen) (v modBits);
SM.bn_precomp_r2_mod_n_lemma (v modBits - 1) (as_seq h n);
let h0 = ST.get () in
BE.mk_bn_mod_exp_precompr2 nLen ke.BE.exp_vt_precomp n r2 s eBits e m_def;
let h1 = ST.get () in
SD.bn_eval_inj (v nLen) (as_seq h1 m_def)
(SE.bn_mod_exp_vartime_precompr2 (v nLen) (as_seq h0 n) (as_seq h0 r2)
(as_seq h1 s) (v eBits) (as_seq h0 e));
if bn_lt_pow2 modBits m_def then true
else false end
else false in
res
inline_for_extraction noextract
let rsapss_verify_bn_to_msg_st (t:limb_t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
saltLen:size_t
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> m:lbignum t (blocks modBits (size (bits t))) ->
Stack bool
(requires fun h ->
live h msg /\ live h m /\ disjoint m msg /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify_bn_to_msg a (v modBits) (v saltLen) (v msgLen) (as_seq h0 msg) (as_seq h0 m))
inline_for_extraction noextract
val rsapss_verify_bn_to_msg:
#t:limb_t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_bn_to_msg_st t a modBits
let rsapss_verify_bn_to_msg #t a modBits saltLen msgLen msg m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let emBits = modBits -! 1ul in
let emLen = blocks emBits 8ul in
[@inline_let] let mLen = blocks emLen (size numb) in
let em = create emLen (u8 0) in
LS.blocks_bits_lemma t (v emBits);
LS.blocks_numb_lemma t (v emBits);
assert (SD.blocks (v emBits) bits == v mLen);
assert (numb * v mLen <= max_size_t);
assert (v mLen <= v nLen);
let m1 = sub m 0ul mLen in
BN.bn_to_bytes_be emLen m1 em;
let res = RP.pss_verify a saltLen msgLen msg emBits em in
pop_frame ();
res
inline_for_extraction noextract
let rsapss_verify_compute_msg_st (t:limb_t) (ke:BE.exp t) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> sgnt:lbuffer uint8 (blocks modBits 8ul)
-> m:lbignum t len ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h sgnt /\ live h pkey /\ live h m /\
disjoint m sgnt /\ disjoint m pkey /\
as_seq h m == LSeq.create (v len) (uint #t 0) /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies (loc m) h0 h1 /\
(r, as_seq h1 m) == LS.rsapss_verify_compute_msg (v modBits) (v eBits) (as_seq h0 pkey) (as_seq h0 sgnt))
inline_for_extraction noextract
val rsapss_verify_compute_msg:
#t:limb_t
-> ke:BE.exp t
-> modBits:modBits_t t ->
rsapss_verify_compute_msg_st t ke modBits
let rsapss_verify_compute_msg #t ke modBits eBits pkey sgnt m =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
[@inline_let] let numb : size_pos = numbytes t in
let nLen = blocks modBits (size bits) in
let k = blocks modBits 8ul in
let s = create nLen (uint #t 0) in
LS.blocks_bits_lemma t (v modBits);
LS.blocks_numb_lemma t (v modBits);
assert (SD.blocks (v k) numb == v nLen);
assert (numb * v nLen <= max_size_t);
BN.bn_from_bytes_be k sgnt s;
let b = rsapss_verify_bn #t ke modBits eBits pkey m s in
pop_frame ();
b
inline_for_extraction noextract
let rsapss_verify_st1 (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> saltLen:size_t
-> sgnt:lbuffer uint8 (blocks modBits 8ul)
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h msg /\ live h sgnt /\ live h pkey /\
disjoint msg sgnt /\ disjoint msg pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey) /\
LS.rsapss_verify_pre a (v saltLen) (v msgLen) (as_seq h msg))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify_ a (v modBits) (v eBits) (as_seq h0 pkey)
(v saltLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_verify_:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_st1 t ke a modBits
let rsapss_verify_ #t ke a modBits eBits pkey saltLen sgnt msgLen msg =
push_frame ();
[@inline_let] let bits : size_pos = bits t in
let nLen = blocks modBits (size bits) in
let m = create nLen (uint #t 0) in
let b = rsapss_verify_compute_msg ke modBits eBits pkey sgnt m in
let res = if b then rsapss_verify_bn_to_msg a modBits saltLen msgLen msg m else false in
pop_frame ();
res
inline_for_extraction noextract
let rsapss_verify_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:modBits_t t) =
let len = blocks modBits (size (bits t)) in
eBits:size_t{LS.pkey_len_pre t (v modBits) (v eBits)}
-> pkey:lbignum t (2ul *! len +! blocks eBits (size (bits t)))
-> saltLen:size_t
-> sgntLen:size_t
-> sgnt:lbuffer uint8 sgntLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen ->
Stack bool
(requires fun h -> len == ke.BE.bn.BN.len /\
live h msg /\ live h sgnt /\ live h pkey /\
disjoint msg sgnt /\ disjoint msg pkey /\
LS.rsapss_pkey_pre (v modBits) (v eBits) (as_seq h pkey))
(ensures fun h0 r h1 -> modifies0 h0 h1 /\
r == LS.rsapss_verify a (v modBits) (v eBits) (as_seq h0 pkey)
(v saltLen) (v sgntLen) (as_seq h0 sgnt) (v msgLen) (as_seq h0 msg))
inline_for_extraction noextract
val rsapss_verify:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t ->
rsapss_verify_st t ke a modBits
let rsapss_verify #t ke a modBits eBits pkey saltLen sgntLen sgnt msgLen msg =
let hLen = RM.hash_len a in
Math.Lemmas.pow2_lt_compat 61 32;
Math.Lemmas.pow2_lt_compat 125 32;
//assert (max_size_t < Hash.max_input_length a);
assert (v msgLen <= max_size_t);
assert (v hLen + 8 < max_size_t);
let b =
saltLen <=. 0xfffffffful -! hLen -! 8ul &&
sgntLen =. blocks modBits 8ul in
if b then
rsapss_verify_ ke a modBits eBits pkey saltLen sgnt msgLen msg
else
false
inline_for_extraction noextract
let rsapss_skey_sign_st (t:limb_t) (ke:BE.exp t) (a:Hash.hash_alg{S.hash_is_supported a}) (modBits:size_t) =
eBits:size_t
-> dBits:size_t{LS.skey_len_pre t (v modBits) (v eBits) (v dBits)}
-> nb:lbuffer uint8 (blocks modBits 8ul)
-> eb:lbuffer uint8 (blocks eBits 8ul)
-> db:lbuffer uint8 (blocks dBits 8ul)
-> saltLen:size_t
-> salt:lbuffer uint8 saltLen
-> msgLen:size_t
-> msg:lbuffer uint8 msgLen
-> sgnt:lbuffer uint8 (blocks modBits 8ul) ->
Stack bool
(requires fun h ->
blocks modBits (size (bits t)) == ke.BE.bn.BN.len /\
live h salt /\ live h msg /\ live h sgnt /\
live h nb /\ live h eb /\ live h db /\
disjoint sgnt salt /\ disjoint sgnt msg /\ disjoint sgnt salt /\
disjoint sgnt nb /\ disjoint sgnt eb /\ disjoint sgnt db /\
disjoint salt msg)
(ensures fun h0 b h1 -> modifies (loc sgnt) h0 h1 /\
(let sgnt_s = S.rsapss_skey_sign a (v modBits) (v eBits) (v dBits)
(as_seq h0 nb) (as_seq h0 eb) (as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) in
if b then Some? sgnt_s /\ as_seq h1 sgnt == Some?.v sgnt_s else None? sgnt_s))
inline_for_extraction noextract
val rsapss_skey_sign:
#t:limb_t
-> ke:BE.exp t
-> a:Hash.hash_alg{S.hash_is_supported a}
-> modBits:modBits_t t
-> rsapss_load_skey:RK.rsapss_load_skey_st t ke modBits
-> rsapss_sign:rsapss_sign_st t ke a modBits ->
rsapss_skey_sign_st t ke a modBits | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Spec.RSAPSS.fst.checked",
"Hacl.Spec.Bignum.Montgomery.fsti.checked",
"Hacl.Spec.Bignum.Exponentiation.fsti.checked",
"Hacl.Spec.Bignum.Definitions.fst.checked",
"Hacl.Spec.Bignum.Base.fst.checked",
"Hacl.Spec.Bignum.fsti.checked",
"Hacl.Impl.RSAPSS.Padding.fst.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Impl.RSAPSS.Keys.fst.checked",
"Hacl.Bignum.Montgomery.fsti.checked",
"Hacl.Bignum.Exponentiation.fsti.checked",
"Hacl.Bignum.Definitions.fst.checked",
"Hacl.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.Math.Lemmas.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Keys",
"short_module": "RK"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": "RM"
},
{
"abbrev": true,
"full_module": "Hacl.Impl.RSAPSS.Padding",
"short_module": "RP"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.RSAPSS",
"short_module": "LS"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Montgomery",
"short_module": "BM"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum.Exponentiation",
"short_module": "BE"
},
{
"abbrev": true,
"full_module": "Hacl.Bignum",
"short_module": "BN"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Exponentiation",
"short_module": "SE"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Montgomery",
"short_module": "SM"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Definitions",
"short_module": "SD"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum.Base",
"short_module": "BB"
},
{
"abbrev": true,
"full_module": "Hacl.Spec.Bignum",
"short_module": "SB"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Bignum.Definitions",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 150,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
ke: Hacl.Bignum.Exponentiation.exp t ->
a: Spec.Hash.Definitions.hash_alg{Spec.RSAPSS.hash_is_supported a} ->
modBits: Hacl.Impl.RSAPSS.modBits_t t ->
rsapss_load_skey: Hacl.Impl.RSAPSS.Keys.rsapss_load_skey_st t ke modBits ->
rsapss_sign: Hacl.Impl.RSAPSS.rsapss_sign_st t ke a modBits
-> Hacl.Impl.RSAPSS.rsapss_skey_sign_st t ke a modBits | Prims.Tot | [
"total"
] | [] | [
"Hacl.Bignum.Definitions.limb_t",
"Hacl.Bignum.Exponentiation.exp",
"Spec.Hash.Definitions.hash_alg",
"Prims.b2t",
"Spec.RSAPSS.hash_is_supported",
"Hacl.Impl.RSAPSS.modBits_t",
"Hacl.Impl.RSAPSS.Keys.rsapss_load_skey_st",
"Hacl.Impl.RSAPSS.rsapss_sign_st",
"Lib.IntTypes.size_t",
"Hacl.Spec.RSAPSS.skey_len_pre",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Hacl.Bignum.Definitions.blocks",
"FStar.UInt32.__uint_to_t",
"Prims.unit",
"Prims._assert",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Prims.bool",
"Lib.Sequence.lseq",
"Hacl.Spec.Bignum.Definitions.blocks",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Hacl.Spec.RSAPSS.rsapss_skey_sign",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"FStar.HyperStack.ST.pop_frame",
"Hacl.Spec.RSAPSS.rsapss_load_skey_lemma",
"Lib.Buffer.lbuffer_t",
"Hacl.Bignum.Definitions.limb",
"Lib.IntTypes.add",
"Lib.IntTypes.mul",
"FStar.UInt32.uint_to_t",
"FStar.UInt32.t",
"Lib.Buffer.create",
"Lib.IntTypes.op_Plus_Bang",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.uint",
"Lib.IntTypes.SEC",
"FStar.HyperStack.ST.push_frame",
"Lib.IntTypes.int_t",
"Lib.IntTypes.size",
"Lib.IntTypes.bits"
] | [] | false | false | false | false | false | let rsapss_skey_sign
#t
ke
a
modBits
rsapss_load_skey
rsapss_sign
eBits
dBits
nb
eb
db
saltLen
salt
msgLen
msg
sgnt
=
| [@@ inline_let ]let bits = size (bits t) in
let h0 = ST.get () in
push_frame ();
let skey =
create (2ul *! blocks modBits bits +! blocks eBits bits +! blocks dBits bits) (uint #t 0)
in
let b = rsapss_load_skey eBits dBits nb eb db skey in
LS.rsapss_load_skey_lemma #t
(v modBits)
(v eBits)
(v dBits)
(as_seq h0 nb)
(as_seq h0 eb)
(as_seq h0 db);
let res = if b then rsapss_sign eBits dBits skey saltLen salt msgLen msg sgnt else false in
pop_frame ();
let h1 = ST.get () in
assert ((res, as_seq h1 sgnt) ==
LS.rsapss_skey_sign #t a (v modBits) (v eBits) (v dBits) (as_seq h0 nb) (as_seq h0 eb)
(as_seq h0 db) (v saltLen) (as_seq h0 salt) (v msgLen) (as_seq h0 msg) (as_seq h0 sgnt));
res | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.name_to_string | val name_to_string (f:R.name) : string | val name_to_string (f:R.name) : string | let name_to_string (f:R.name) = String.concat "." f | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 51,
"end_line": 32,
"start_col": 0,
"start_line": 32
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost" | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | f: FStar.Stubs.Reflection.Types.name -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"FStar.Stubs.Reflection.Types.name",
"FStar.String.concat",
"Prims.string"
] | [] | false | false | false | true | false | let name_to_string (f: R.name) =
| String.concat "." f | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_to_bytes_be | val vecs_to_bytes_be: #vt:v_inttype -> #w:width -> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len -> lseq uint8 (len * (numbytes vt * w)) | val vecs_to_bytes_be: #vt:v_inttype -> #w:width -> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len -> lseq uint8 (len * (numbytes vt * w)) | let vecs_to_bytes_be #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_be_f #vt #w #len vl) () in
o | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 3,
"end_line": 80,
"start_col": 0,
"start_line": 76
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i]
let vecs_to_bytes_le #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_le_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_le #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_le_f #vt #w #len vl) i
val vecs_to_bytes_be_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_be_f #vt #w #len vl i () =
(), vec_to_bytes_be vl.[i] | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | vl: Lib.Sequence.lseq (Lib.IntVector.vec_t vt w) len
-> Lib.Sequence.lseq Lib.IntTypes.uint8 (len * (Lib.IntTypes.numbytes vt * w)) | Prims.Tot | [
"total"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Lib.Sequence.seq",
"Lib.IntTypes.uint8",
"Prims.eq2",
"Prims.int",
"Lib.Sequence.length",
"FStar.Pervasives.Native.tuple2",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Prims.op_Multiply",
"Lib.Sequence.generate_blocks",
"Lib.IntVector.Serialize.vecs_to_bytes_be_f",
"Prims.eqtype",
"Prims.unit"
] | [] | false | false | false | false | false | let vecs_to_bytes_be #vt #w #len vl =
| let a_spec (i: nat{i <= len}) = unit in
let _, o =
generate_blocks (numbytes vt * w) len len a_spec (vecs_to_bytes_be_f #vt #w #len vl) ()
in
o | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.univ_to_string | val univ_to_string (u:universe) : string | val univ_to_string (u:universe) : string | let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u) | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 62,
"end_line": 56,
"start_col": 0,
"start_line": 56
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>" | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | u14: Pulse.Syntax.Base.universe -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Pulse.Syntax.Base.universe",
"FStar.Printf.sprintf",
"Pulse.Syntax.Printer.universe_to_string",
"Prims.string"
] | [] | false | false | false | true | false | let univ_to_string u =
| sprintf "u#%s" (universe_to_string 0 u) | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.dbg_printing | val dbg_printing:bool | val dbg_printing:bool | let dbg_printing : bool = true | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 30,
"end_line": 34,
"start_col": 0,
"start_line": 34
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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.bool | Prims.Tot | [
"total"
] | [] | [] | [] | false | false | false | true | false | let dbg_printing:bool =
| true | false |
Hacl.Frodo.KEM.fst | Hacl.Frodo.KEM.crypto_kem_enc_st | val crypto_kem_enc_st : a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a}
-> Type0 | let crypto_kem_enc_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack uint32
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint state ct /\ disjoint state ss /\ disjoint state pk)
(ensures fun h0 _ h1 -> modifies (loc state |+| (loc ct |+| loc ss)) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc a gen_a (as_seq h0 state) (as_seq h0 pk)) | {
"file_name": "code/frodo/Hacl.Frodo.KEM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 96,
"end_line": 48,
"start_col": 0,
"start_line": 38
} | module Hacl.Frodo.KEM
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Frodo.Random
module S = Spec.Frodo.KEM
module FP = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let crypto_kem_keypair_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
pk:lbytes (crypto_publickeybytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h pk /\ live h sk /\
disjoint pk sk /\ disjoint state pk /\ disjoint state sk)
(ensures fun h0 r h1 -> modifies (loc state |+| (loc pk |+| loc sk)) h0 h1 /\
(as_seq h1 pk, as_seq h1 sk) == S.crypto_kem_keypair a gen_a (as_seq h0 state))
inline_for_extraction noextract
val crypto_kem_keypair: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_keypair_st a gen_a
let crypto_kem_keypair a gen_a pk sk =
Hacl.Impl.Frodo.KEM.KeyGen.crypto_kem_keypair a gen_a pk sk | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.Decaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Frodo.KEM.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"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": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a}
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"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.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_publickeybytes",
"Lib.IntTypes.uint32",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.Buffer.disjoint",
"Hacl.Frodo.Random.state",
"Lib.Buffer.modifies",
"Lib.Buffer.op_Bar_Plus_Bar",
"Lib.Buffer.loc",
"Prims.eq2",
"FStar.Pervasives.Native.tuple2",
"Lib.ByteSequence.lbytes",
"Spec.Frodo.Params.crypto_ciphertextbytes",
"Spec.Frodo.Params.crypto_bytes",
"FStar.Pervasives.Native.Mktuple2",
"Lib.Sequence.lseq",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.Buffer.as_seq",
"Spec.Frodo.KEM.crypto_kem_enc",
"FStar.UInt32.__uint_to_t"
] | [] | false | false | false | false | true | let crypto_kem_enc_st (a: FP.frodo_alg) (gen_a: FP.frodo_gen_a{is_supported gen_a}) =
|
ct: lbytes (crypto_ciphertextbytes a) ->
ss: lbytes (crypto_bytes a) ->
pk: lbytes (crypto_publickeybytes a)
-> Stack uint32
(requires
fun h ->
live h ct /\ live h ss /\ live h pk /\ disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint state ct /\ disjoint state ss /\ disjoint state pk)
(ensures
fun h0 _ h1 ->
modifies (loc state |+| (loc ct |+| loc ss)) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc a gen_a (as_seq h0 state) (as_seq h0 pk)) | false |
|
LowParse.SLow.BCVLI.fst | LowParse.SLow.BCVLI.serialize32_bcvli | val serialize32_bcvli:serializer32 serialize_bcvli | val serialize32_bcvli:serializer32 serialize_bcvli | let serialize32_bcvli
: serializer32 serialize_bcvli
= fun x -> ((
[@inline_let] let _ = serialize_bcvli_eq x in
let c1 : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
let s1 = serialize32_bounded_integer_le_1 c1 in
if c1 `U32.lt` 253ul
then s1
else if c1 = 253ul
then s1 `B32.append` serialize32_bounded_integer_le_2 x
else s1 `B32.append` serialize32_bounded_integer_le_4 x
) <: (res: bytes32 { serializer32_correct' serialize_bcvli x res } )) | {
"file_name": "src/lowparse/LowParse.SLow.BCVLI.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 71,
"end_line": 61,
"start_col": 0,
"start_line": 44
} | module LowParse.SLow.BCVLI
include LowParse.Spec.BCVLI
include LowParse.SLow.Combinators // for make_total_constant_size_parser32
include LowParse.SLow.BoundedInt // for bounded_integer_le
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
module Cast = FStar.Int.Cast
#push-options "--max_fuel 0"
let parse32_bcvli
: parser32 parse_bcvli
= fun input -> ((
[@inline_let] let _ =
parse_bcvli_eq (B32.reveal input)
in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul
then Some (x32, consumed_x)
else
let input' = B32.slice input consumed_x (B32.len input) in
if x32 = 253ul
then
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 253ul then None else Some (y, consumed_x `U32.add` consumed_y)
else if x32 = 254ul
then
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 65536ul then None else Some (y, consumed_x `U32.add` consumed_y)
else
None
) <: (res: _ { parser32_correct parse_bcvli input res } ))
module U8 = FStar.UInt8 | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.SLow.BoundedInt.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.BCVLI.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.serializer32 LowParse.Spec.BCVLI.serialize_bcvli | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"Prims.op_Equality",
"FStar.Bytes.append",
"LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_2",
"LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_4",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.Base.serializer32_correct'",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bcvli",
"LowParse.Spec.BCVLI.serialize_bcvli",
"LowParse.SLow.Base.serializer32_correct",
"LowParse.Spec.BoundedInt.parse_bounded_integer_kind",
"LowParse.Spec.BoundedInt.bounded_integer",
"LowParse.Spec.BoundedInt.parse_bounded_integer_le",
"LowParse.Spec.BoundedInt.serialize_bounded_integer_le",
"LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_1",
"Prims.unit",
"LowParse.Spec.BCVLI.serialize_bcvli_eq"
] | [] | false | false | false | true | false | let serialize32_bcvli:serializer32 serialize_bcvli =
| fun x ->
(([@@ inline_let ]let _ = serialize_bcvli_eq x in
let c1:bounded_integer 1 =
if x `U32.lt` 253ul then x else if x `U32.lt` 65536ul then 253ul else 254ul
in
let s1 = serialize32_bounded_integer_le_1 c1 in
if c1 `U32.lt` 253ul
then s1
else
if c1 = 253ul
then s1 `B32.append` (serialize32_bounded_integer_le_2 x)
else s1 `B32.append` (serialize32_bounded_integer_le_4 x))
<:
(res: bytes32{serializer32_correct' serialize_bcvli x res})) | false |
LowParse.SLow.BCVLI.fst | LowParse.SLow.BCVLI.size32_bcvli | val size32_bcvli:size32 serialize_bcvli | val size32_bcvli:size32 serialize_bcvli | let size32_bcvli
: size32 serialize_bcvli
= fun x -> ((
[@inline_let] let _ = serialize_bcvli_eq x in
if x `U32.lt` 253ul
then 1ul
else if x `U32.lt` 65536ul
then 3ul
else 5ul
) <: (res: _ { size32_postcond serialize_bcvli x res } )) | {
"file_name": "src/lowparse/LowParse.SLow.BCVLI.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 59,
"end_line": 72,
"start_col": 0,
"start_line": 63
} | module LowParse.SLow.BCVLI
include LowParse.Spec.BCVLI
include LowParse.SLow.Combinators // for make_total_constant_size_parser32
include LowParse.SLow.BoundedInt // for bounded_integer_le
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
module Cast = FStar.Int.Cast
#push-options "--max_fuel 0"
let parse32_bcvli
: parser32 parse_bcvli
= fun input -> ((
[@inline_let] let _ =
parse_bcvli_eq (B32.reveal input)
in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul
then Some (x32, consumed_x)
else
let input' = B32.slice input consumed_x (B32.len input) in
if x32 = 253ul
then
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 253ul then None else Some (y, consumed_x `U32.add` consumed_y)
else if x32 = 254ul
then
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 65536ul then None else Some (y, consumed_x `U32.add` consumed_y)
else
None
) <: (res: _ { parser32_correct parse_bcvli input res } ))
module U8 = FStar.UInt8
let serialize32_bcvli
: serializer32 serialize_bcvli
= fun x -> ((
[@inline_let] let _ = serialize_bcvli_eq x in
let c1 : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
let s1 = serialize32_bounded_integer_le_1 c1 in
if c1 `U32.lt` 253ul
then s1
else if c1 = 253ul
then s1 `B32.append` serialize32_bounded_integer_le_2 x
else s1 `B32.append` serialize32_bounded_integer_le_4 x
) <: (res: bytes32 { serializer32_correct' serialize_bcvli x res } )) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.SLow.BoundedInt.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.BCVLI.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.size32 LowParse.Spec.BCVLI.serialize_bcvli | Prims.Tot | [
"total"
] | [] | [
"FStar.UInt32.t",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"Prims.bool",
"LowParse.SLow.Base.size32_postcond",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bcvli",
"LowParse.Spec.BCVLI.serialize_bcvli",
"Prims.unit",
"LowParse.Spec.BCVLI.serialize_bcvli_eq"
] | [] | false | false | false | true | false | let size32_bcvli:size32 serialize_bcvli =
| fun x ->
(([@@ inline_let ]let _ = serialize_bcvli_eq x in
if x `U32.lt` 253ul then 1ul else if x `U32.lt` 65536ul then 3ul else 5ul)
<:
(res: _{size32_postcond serialize_bcvli x res})) | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.indent | val indent : level: Prims.string -> Prims.string | let indent (level:string) = level ^ "\t" | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 40,
"end_line": 61,
"start_col": 0,
"start_line": 61
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>"
let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u)
let qual_to_string = function
| None -> ""
| Some Implicit -> "#" | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | level: Prims.string -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Prims.string",
"Prims.op_Hat"
] | [] | false | false | false | true | false | let indent (level: string) =
| level ^ "\t" | false |
|
Hacl.Impl.RSAPSS.Padding.fst | Hacl.Impl.RSAPSS.Padding.salt_len_t | val salt_len_t : a: Spec.Hash.Definitions.fixed_len_alg -> Type0 | let salt_len_t (a:Hash.fixed_len_alg) =
saltLen:size_t{8 + Hash.hash_length a + v saltLen <= max_size_t /\ (8 + Hash.hash_length a + v saltLen) `less_than_max_input_length` a} | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.Padding.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 137,
"end_line": 27,
"start_col": 0,
"start_line": 26
} | module Hacl.Impl.RSAPSS.Padding
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.RSAPSS.MGF
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
module S = Spec.RSAPSS
module BD = Hacl.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.Padding.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.fixed_len_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.fixed_len_alg",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Spec.Hash.Definitions.hash_length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.max_size_t",
"Hacl.Impl.RSAPSS.Padding.less_than_max_input_length"
] | [] | false | false | false | true | true | let salt_len_t (a: Hash.fixed_len_alg) =
| saltLen:
size_t
{ 8 + Hash.hash_length a + v saltLen <= max_size_t /\
(8 + Hash.hash_length a + v saltLen) `less_than_max_input_length` a } | false |
|
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.term_to_string | val term_to_string (t:term) : T.Tac string | val term_to_string (t:term) : T.Tac string | let term_to_string t = term_to_string' "" t | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 43,
"end_line": 126,
"start_col": 0,
"start_line": 126
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>"
let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u)
let qual_to_string = function
| None -> ""
| Some Implicit -> "#"
let indent (level:string) = level ^ "\t"
let rec collect_binders (until: term' -> bool) (t:term) : list binder & term =
if not (until t.t) then [], t
else (
match t.t with
| Tm_ExistsSL _ b body
| Tm_ForallSL _ b body ->
let bs, t = collect_binders until body in
b::bs, t
| _ -> [], t
)
let rec binder_to_string_paren (b:binder)
: T.Tac string
= sprintf "(%s%s:%s)"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string' "" b.binder_ty)
and term_to_string' (level:string) (t:term)
: T.Tac string
= match t.t with
| Tm_Emp -> "emp"
| Tm_Pure p ->
sprintf "pure (%s)"
(term_to_string' (indent level) p)
| Tm_Star p1 p2 ->
sprintf "%s ** \n%s%s"
(term_to_string' level p1)
level
(term_to_string' level p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
sprintf "(exists* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_ForallSL u b body ->
let bs, body = collect_binders Tm_ForallSL? t in
sprintf "(forall* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_VProp -> "vprop"
| Tm_Inames -> "inames"
| Tm_EmpInames -> "emp_inames"
| Tm_Unknown -> "_"
| Tm_AddInv i is ->
sprintf "add_inv %s %s"
(term_to_string' level i)
(term_to_string' level is)
| Tm_Inv i ->
sprintf "inv %s"
(term_to_string' level i)
| Tm_FStar t -> | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | t: Pulse.Syntax.Base.term -> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Printer.term_to_string'",
"Prims.string"
] | [] | false | true | false | false | false | let term_to_string t =
| term_to_string' "" t | false |
Hacl.Impl.RSAPSS.Padding.fst | Hacl.Impl.RSAPSS.Padding.less_than_max_input_length | val less_than_max_input_length : l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool | let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.Padding.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 81,
"end_line": 23,
"start_col": 0,
"start_line": 23
} | module Hacl.Impl.RSAPSS.Padding
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.RSAPSS.MGF
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
module S = Spec.RSAPSS
module BD = Hacl.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0" | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.Padding.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | l: Prims.int -> a: Spec.Hash.Definitions.hash_alg -> Prims.bool | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.less_than_max_input_length"
] | [] | false | false | false | true | false | let less_than_max_input_length =
| Spec.Hash.Definitions.less_than_max_input_length | false |
|
Hacl.Impl.RSAPSS.Padding.fst | Hacl.Impl.RSAPSS.Padding.msg_len_t | val msg_len_t : a: Spec.Hash.Definitions.fixed_len_alg -> Type0 | let msg_len_t (a:Hash.fixed_len_alg) =
msgLen:size_t{v msgLen `less_than_max_input_length` a} | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.Padding.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 56,
"end_line": 31,
"start_col": 0,
"start_line": 30
} | module Hacl.Impl.RSAPSS.Padding
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.RSAPSS.MGF
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
module S = Spec.RSAPSS
module BD = Hacl.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length
inline_for_extraction noextract
let salt_len_t (a:Hash.fixed_len_alg) =
saltLen:size_t{8 + Hash.hash_length a + v saltLen <= max_size_t /\ (8 + Hash.hash_length a + v saltLen) `less_than_max_input_length` a} | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.Padding.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.fixed_len_alg -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.fixed_len_alg",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Hacl.Impl.RSAPSS.Padding.less_than_max_input_length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB"
] | [] | false | false | false | true | true | let msg_len_t (a: Hash.fixed_len_alg) =
| msgLen: size_t{(v msgLen) `less_than_max_input_length` a} | false |
|
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.binder_to_string | val binder_to_string (b:binder) : T.Tac string | val binder_to_string (b:binder) : T.Tac string | let binder_to_string (b:binder)
: T.Tac string
= sprintf "%s%s:%s"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string b.binder_ty) | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 40,
"end_line": 175,
"start_col": 0,
"start_line": 168
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>"
let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u)
let qual_to_string = function
| None -> ""
| Some Implicit -> "#"
let indent (level:string) = level ^ "\t"
let rec collect_binders (until: term' -> bool) (t:term) : list binder & term =
if not (until t.t) then [], t
else (
match t.t with
| Tm_ExistsSL _ b body
| Tm_ForallSL _ b body ->
let bs, t = collect_binders until body in
b::bs, t
| _ -> [], t
)
let rec binder_to_string_paren (b:binder)
: T.Tac string
= sprintf "(%s%s:%s)"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string' "" b.binder_ty)
and term_to_string' (level:string) (t:term)
: T.Tac string
= match t.t with
| Tm_Emp -> "emp"
| Tm_Pure p ->
sprintf "pure (%s)"
(term_to_string' (indent level) p)
| Tm_Star p1 p2 ->
sprintf "%s ** \n%s%s"
(term_to_string' level p1)
level
(term_to_string' level p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
sprintf "(exists* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_ForallSL u b body ->
let bs, body = collect_binders Tm_ForallSL? t in
sprintf "(forall* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_VProp -> "vprop"
| Tm_Inames -> "inames"
| Tm_EmpInames -> "emp_inames"
| Tm_Unknown -> "_"
| Tm_AddInv i is ->
sprintf "add_inv %s %s"
(term_to_string' level i)
(term_to_string' level is)
| Tm_Inv i ->
sprintf "inv %s"
(term_to_string' level i)
| Tm_FStar t ->
T.term_to_string t
let term_to_string t = term_to_string' "" t
let rec binder_to_doc b : T.Tac document =
parens (doc_of_string (T.unseal b.binder_ppname.name)
^^ doc_of_string ":"
^^ term_to_doc b.binder_ty)
and term_to_doc t
: T.Tac document
= match t.t with
| Tm_Emp -> doc_of_string "emp"
| Tm_Pure p -> doc_of_string "pure" ^^ parens (term_to_doc p)
| Tm_Star p1 p2 ->
infix 2 1 (doc_of_string "**")
(term_to_doc p1)
(term_to_doc p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
parens (doc_of_string "exists*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_ForallSL _ _ _ ->
let bs, body = collect_binders Tm_ForallSL? t in
parens (doc_of_string "forall*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_VProp -> doc_of_string "vprop"
| Tm_Inames -> doc_of_string "inames"
| Tm_EmpInames -> doc_of_string "emp_inames"
| Tm_AddInv i is ->
doc_of_string "add_inv" ^/^ parens (term_to_doc i ^^ doc_of_string "," ^^ term_to_doc is)
| Tm_Inv i ->
doc_of_string "inv" ^/^ parens (term_to_doc i)
| Tm_Unknown -> doc_of_string "_"
| Tm_FStar t ->
// Should call term_to_doc when available
doc_of_string (T.term_to_string t) | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | b: Pulse.Syntax.Base.binder -> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Syntax.Base.binder",
"Prims.string",
"FStar.Printf.sprintf",
"Prims.list",
"Pulse.Syntax.Base.term",
"FStar.String.concat",
"FStar.Tactics.Util.map",
"Pulse.Syntax.Printer.term_to_string'",
"FStar.Tactics.Unseal.unseal",
"Pulse.Syntax.Base.__proj__Mkbinder__item__binder_attrs",
"Pulse.Syntax.Base.__proj__Mkppname__item__name",
"Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ppname",
"Pulse.Syntax.Printer.term_to_string",
"Pulse.Syntax.Base.__proj__Mkbinder__item__binder_ty"
] | [] | false | true | false | false | false | let binder_to_string (b: binder) : T.Tac string =
| sprintf "%s%s:%s"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string b.binder_ty) | false |
Hacl.Frodo.KEM.fst | Hacl.Frodo.KEM.crypto_kem_dec_st | val crypto_kem_dec_st : a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a}
-> Type0 | let crypto_kem_dec_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
ss:lbytes (crypto_bytes a)
-> ct:lbytes (crypto_ciphertextbytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h ss /\ live h ct /\ live h sk /\
disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk)
(ensures fun h0 r h1 -> modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk)) | {
"file_name": "code/frodo/Hacl.Frodo.KEM.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 77,
"end_line": 67,
"start_col": 0,
"start_line": 58
} | module Hacl.Frodo.KEM
open FStar.HyperStack
open FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.Matrix
open Hacl.Impl.Frodo.Params
open Hacl.Impl.Frodo.KEM
open Hacl.Frodo.Random
module S = Spec.Frodo.KEM
module FP = Spec.Frodo.Params
#set-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let crypto_kem_keypair_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
pk:lbytes (crypto_publickeybytes a)
-> sk:lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires fun h ->
live h pk /\ live h sk /\
disjoint pk sk /\ disjoint state pk /\ disjoint state sk)
(ensures fun h0 r h1 -> modifies (loc state |+| (loc pk |+| loc sk)) h0 h1 /\
(as_seq h1 pk, as_seq h1 sk) == S.crypto_kem_keypair a gen_a (as_seq h0 state))
inline_for_extraction noextract
val crypto_kem_keypair: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_keypair_st a gen_a
let crypto_kem_keypair a gen_a pk sk =
Hacl.Impl.Frodo.KEM.KeyGen.crypto_kem_keypair a gen_a pk sk
inline_for_extraction noextract
let crypto_kem_enc_st (a:FP.frodo_alg) (gen_a:FP.frodo_gen_a{is_supported gen_a}) =
ct:lbytes (crypto_ciphertextbytes a)
-> ss:lbytes (crypto_bytes a)
-> pk:lbytes (crypto_publickeybytes a)
-> Stack uint32
(requires fun h ->
live h ct /\ live h ss /\ live h pk /\
disjoint ct ss /\ disjoint ct pk /\ disjoint ss pk /\
disjoint state ct /\ disjoint state ss /\ disjoint state pk)
(ensures fun h0 _ h1 -> modifies (loc state |+| (loc ct |+| loc ss)) h0 h1 /\
(as_seq h1 ct, as_seq h1 ss) == S.crypto_kem_enc a gen_a (as_seq h0 state) (as_seq h0 pk))
inline_for_extraction noextract
val crypto_kem_enc: a:FP.frodo_alg -> gen_a:FP.frodo_gen_a{is_supported gen_a} -> crypto_kem_enc_st a gen_a
let crypto_kem_enc a gen_a ct ss pk =
Hacl.Impl.Frodo.KEM.Encaps.crypto_kem_enc a gen_a ct ss pk | {
"checked_file": "/",
"dependencies": [
"Spec.Frodo.Params.fst.checked",
"Spec.Frodo.KEM.fst.checked",
"prims.fst.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.Matrix.fst.checked",
"Hacl.Impl.Frodo.Params.fst.checked",
"Hacl.Impl.Frodo.KEM.KeyGen.fst.checked",
"Hacl.Impl.Frodo.KEM.Encaps.fst.checked",
"Hacl.Impl.Frodo.KEM.Decaps.fst.checked",
"Hacl.Impl.Frodo.KEM.fst.checked",
"Hacl.Frodo.Random.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Frodo.KEM.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.Frodo.Params",
"short_module": "FP"
},
{
"abbrev": true,
"full_module": "Spec.Frodo.KEM",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Frodo.Random",
"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": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Frodo",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
a: Spec.Frodo.Params.frodo_alg ->
gen_a: Spec.Frodo.Params.frodo_gen_a{Hacl.Impl.Frodo.Params.is_supported gen_a}
-> Type0 | Prims.Tot | [
"total"
] | [] | [
"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.crypto_bytes",
"Hacl.Impl.Frodo.Params.crypto_ciphertextbytes",
"Hacl.Impl.Frodo.Params.crypto_secretkeybytes",
"Lib.IntTypes.uint32",
"FStar.Monotonic.HyperStack.mem",
"Prims.l_and",
"Lib.Buffer.live",
"Lib.Buffer.MUT",
"Lib.IntTypes.uint8",
"Lib.Buffer.disjoint",
"Lib.Buffer.modifies",
"Lib.Buffer.loc",
"Prims.eq2",
"Lib.Sequence.seq",
"Prims.l_or",
"Prims.nat",
"FStar.Seq.Base.length",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.uint_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Spec.Frodo.Params.crypto_bytes",
"Lib.Buffer.as_seq",
"Spec.Frodo.KEM.crypto_kem_dec"
] | [] | false | false | false | false | true | let crypto_kem_dec_st (a: FP.frodo_alg) (gen_a: FP.frodo_gen_a{is_supported gen_a}) =
|
ss: lbytes (crypto_bytes a) ->
ct: lbytes (crypto_ciphertextbytes a) ->
sk: lbytes (crypto_secretkeybytes a)
-> Stack uint32
(requires
fun h ->
live h ss /\ live h ct /\ live h sk /\ disjoint ss ct /\ disjoint ss sk /\ disjoint ct sk)
(ensures
fun h0 r h1 ->
modifies (loc ss) h0 h1 /\
as_seq h1 ss == S.crypto_kem_dec a gen_a (as_seq h0 ct) (as_seq h0 sk)) | false |
|
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.term_list_to_string | val term_list_to_string (sep:string) (t:list term): T.Tac string | val term_list_to_string (sep:string) (t:list term): T.Tac string | let term_list_to_string (sep:string) (t:list term)
: T.Tac string
= String.concat sep (T.map term_to_string t) | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 46,
"end_line": 227,
"start_col": 0,
"start_line": 225
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>"
let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u)
let qual_to_string = function
| None -> ""
| Some Implicit -> "#"
let indent (level:string) = level ^ "\t"
let rec collect_binders (until: term' -> bool) (t:term) : list binder & term =
if not (until t.t) then [], t
else (
match t.t with
| Tm_ExistsSL _ b body
| Tm_ForallSL _ b body ->
let bs, t = collect_binders until body in
b::bs, t
| _ -> [], t
)
let rec binder_to_string_paren (b:binder)
: T.Tac string
= sprintf "(%s%s:%s)"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string' "" b.binder_ty)
and term_to_string' (level:string) (t:term)
: T.Tac string
= match t.t with
| Tm_Emp -> "emp"
| Tm_Pure p ->
sprintf "pure (%s)"
(term_to_string' (indent level) p)
| Tm_Star p1 p2 ->
sprintf "%s ** \n%s%s"
(term_to_string' level p1)
level
(term_to_string' level p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
sprintf "(exists* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_ForallSL u b body ->
let bs, body = collect_binders Tm_ForallSL? t in
sprintf "(forall* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_VProp -> "vprop"
| Tm_Inames -> "inames"
| Tm_EmpInames -> "emp_inames"
| Tm_Unknown -> "_"
| Tm_AddInv i is ->
sprintf "add_inv %s %s"
(term_to_string' level i)
(term_to_string' level is)
| Tm_Inv i ->
sprintf "inv %s"
(term_to_string' level i)
| Tm_FStar t ->
T.term_to_string t
let term_to_string t = term_to_string' "" t
let rec binder_to_doc b : T.Tac document =
parens (doc_of_string (T.unseal b.binder_ppname.name)
^^ doc_of_string ":"
^^ term_to_doc b.binder_ty)
and term_to_doc t
: T.Tac document
= match t.t with
| Tm_Emp -> doc_of_string "emp"
| Tm_Pure p -> doc_of_string "pure" ^^ parens (term_to_doc p)
| Tm_Star p1 p2 ->
infix 2 1 (doc_of_string "**")
(term_to_doc p1)
(term_to_doc p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
parens (doc_of_string "exists*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_ForallSL _ _ _ ->
let bs, body = collect_binders Tm_ForallSL? t in
parens (doc_of_string "forall*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_VProp -> doc_of_string "vprop"
| Tm_Inames -> doc_of_string "inames"
| Tm_EmpInames -> doc_of_string "emp_inames"
| Tm_AddInv i is ->
doc_of_string "add_inv" ^/^ parens (term_to_doc i ^^ doc_of_string "," ^^ term_to_doc is)
| Tm_Inv i ->
doc_of_string "inv" ^/^ parens (term_to_doc i)
| Tm_Unknown -> doc_of_string "_"
| Tm_FStar t ->
// Should call term_to_doc when available
doc_of_string (T.term_to_string t)
let binder_to_string (b:binder)
: T.Tac string
= sprintf "%s%s:%s"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string b.binder_ty)
let ctag_to_string = function
| STT -> "ST"
| STT_Atomic -> "STAtomic"
| STT_Ghost -> "STGhost"
let observability_to_string =
function
| Observable -> "Observable"
| Unobservable -> "Unobservable"
| Neutral -> "Neutral"
let effect_annot_to_string = function
| EffectAnnotSTT -> "stt"
| EffectAnnotGhost -> "stt_ghost"
| EffectAnnotAtomic { opens } -> sprintf "stt_atomic %s" (term_to_string opens)
let comp_to_string (c:comp)
: T.Tac string
= match c with
| C_Tot t ->
sprintf "Tot %s" (term_to_string t)
| C_ST s ->
sprintf "stt %s (requires\n%s) (ensures\n%s)"
(term_to_string s.res)
(term_to_string s.pre)
(term_to_string s.post)
| C_STAtomic inames obs s ->
sprintf "stt_atomic %s #%s %s (requires\n%s) (ensures\n%s)"
(term_to_string s.res)
(observability_to_string obs)
(term_to_string inames)
(term_to_string s.pre)
(term_to_string s.post)
| C_STGhost s ->
sprintf "stt_ghost %s (requires\n%s) (ensures\n%s)"
(term_to_string s.res)
(term_to_string s.pre)
(term_to_string s.post)
let term_opt_to_string (t:option term)
: T.Tac string
= match t with
| None -> ""
| Some t -> term_to_string t | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | sep: Prims.string -> t: Prims.list Pulse.Syntax.Base.term -> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"Prims.string",
"Prims.list",
"Pulse.Syntax.Base.term",
"FStar.String.concat",
"FStar.Tactics.Util.map",
"Pulse.Syntax.Printer.term_to_string"
] | [] | false | true | false | false | false | let term_list_to_string (sep: string) (t: list term) : T.Tac string =
| String.concat sep (T.map term_to_string t) | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.st_term_to_string | val st_term_to_string (t:st_term) : T.Tac string | val st_term_to_string (t:st_term) : T.Tac string | let st_term_to_string t = st_term_to_string' "" t | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 49,
"end_line": 432,
"start_col": 0,
"start_line": 432
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>"
let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u)
let qual_to_string = function
| None -> ""
| Some Implicit -> "#"
let indent (level:string) = level ^ "\t"
let rec collect_binders (until: term' -> bool) (t:term) : list binder & term =
if not (until t.t) then [], t
else (
match t.t with
| Tm_ExistsSL _ b body
| Tm_ForallSL _ b body ->
let bs, t = collect_binders until body in
b::bs, t
| _ -> [], t
)
let rec binder_to_string_paren (b:binder)
: T.Tac string
= sprintf "(%s%s:%s)"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string' "" b.binder_ty)
and term_to_string' (level:string) (t:term)
: T.Tac string
= match t.t with
| Tm_Emp -> "emp"
| Tm_Pure p ->
sprintf "pure (%s)"
(term_to_string' (indent level) p)
| Tm_Star p1 p2 ->
sprintf "%s ** \n%s%s"
(term_to_string' level p1)
level
(term_to_string' level p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
sprintf "(exists* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_ForallSL u b body ->
let bs, body = collect_binders Tm_ForallSL? t in
sprintf "(forall* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_VProp -> "vprop"
| Tm_Inames -> "inames"
| Tm_EmpInames -> "emp_inames"
| Tm_Unknown -> "_"
| Tm_AddInv i is ->
sprintf "add_inv %s %s"
(term_to_string' level i)
(term_to_string' level is)
| Tm_Inv i ->
sprintf "inv %s"
(term_to_string' level i)
| Tm_FStar t ->
T.term_to_string t
let term_to_string t = term_to_string' "" t
let rec binder_to_doc b : T.Tac document =
parens (doc_of_string (T.unseal b.binder_ppname.name)
^^ doc_of_string ":"
^^ term_to_doc b.binder_ty)
and term_to_doc t
: T.Tac document
= match t.t with
| Tm_Emp -> doc_of_string "emp"
| Tm_Pure p -> doc_of_string "pure" ^^ parens (term_to_doc p)
| Tm_Star p1 p2 ->
infix 2 1 (doc_of_string "**")
(term_to_doc p1)
(term_to_doc p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
parens (doc_of_string "exists*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_ForallSL _ _ _ ->
let bs, body = collect_binders Tm_ForallSL? t in
parens (doc_of_string "forall*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_VProp -> doc_of_string "vprop"
| Tm_Inames -> doc_of_string "inames"
| Tm_EmpInames -> doc_of_string "emp_inames"
| Tm_AddInv i is ->
doc_of_string "add_inv" ^/^ parens (term_to_doc i ^^ doc_of_string "," ^^ term_to_doc is)
| Tm_Inv i ->
doc_of_string "inv" ^/^ parens (term_to_doc i)
| Tm_Unknown -> doc_of_string "_"
| Tm_FStar t ->
// Should call term_to_doc when available
doc_of_string (T.term_to_string t)
let binder_to_string (b:binder)
: T.Tac string
= sprintf "%s%s:%s"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string b.binder_ty)
let ctag_to_string = function
| STT -> "ST"
| STT_Atomic -> "STAtomic"
| STT_Ghost -> "STGhost"
let observability_to_string =
function
| Observable -> "Observable"
| Unobservable -> "Unobservable"
| Neutral -> "Neutral"
let effect_annot_to_string = function
| EffectAnnotSTT -> "stt"
| EffectAnnotGhost -> "stt_ghost"
| EffectAnnotAtomic { opens } -> sprintf "stt_atomic %s" (term_to_string opens)
let comp_to_string (c:comp)
: T.Tac string
= match c with
| C_Tot t ->
sprintf "Tot %s" (term_to_string t)
| C_ST s ->
sprintf "stt %s (requires\n%s) (ensures\n%s)"
(term_to_string s.res)
(term_to_string s.pre)
(term_to_string s.post)
| C_STAtomic inames obs s ->
sprintf "stt_atomic %s #%s %s (requires\n%s) (ensures\n%s)"
(term_to_string s.res)
(observability_to_string obs)
(term_to_string inames)
(term_to_string s.pre)
(term_to_string s.post)
| C_STGhost s ->
sprintf "stt_ghost %s (requires\n%s) (ensures\n%s)"
(term_to_string s.res)
(term_to_string s.pre)
(term_to_string s.post)
let term_opt_to_string (t:option term)
: T.Tac string
= match t with
| None -> ""
| Some t -> term_to_string t
let term_list_to_string (sep:string) (t:list term)
: T.Tac string
= String.concat sep (T.map term_to_string t)
let rec st_term_to_string' (level:string) (t:st_term)
: T.Tac string
= match t.term with
| Tm_Return { insert_eq; term } ->
sprintf "return_%s %s"
(if insert_eq then "" else "_noeq")
(term_to_string term)
| Tm_STApp {head; arg_qual; arg } ->
sprintf "(%s%s %s%s)"
(if dbg_printing then "<stapp>" else "")
(term_to_string head)
(qual_to_string arg_qual)
(term_to_string arg)
| Tm_Bind { binder; head; body } ->
// if T.unseal binder.binder_ppname.name = "_"
// then sprintf "%s;\n%s%s"
// (st_term_to_string' level head)
// level
// (st_term_to_string' level body)
// else (
sprintf "let %s = %s;\n%s%s"
(binder_to_string binder)
(st_term_to_string' level head)
level
(st_term_to_string' level body)
// )
| Tm_TotBind { head; binder; body } ->
sprintf "let tot %s = %s;\n%s%s"
(binder_to_string binder)
(term_to_string head)
level
(st_term_to_string' level body)
| Tm_Abs { b; q; ascription=c; body } ->
sprintf "(fun (%s%s)\n%s\n ({\n%s%s\n}%s)"
(qual_to_string q)
(binder_to_string b)
(match c.annotated with | None -> "" | Some c -> comp_to_string c)
(indent level)
(st_term_to_string' (indent level) body)
(match c.elaborated with | None -> "" | Some c -> " <: " ^ comp_to_string c)
| Tm_If { b; then_; else_ } ->
sprintf "if (%s)\n%s{\n%s%s\n%s}\n%selse\n%s{\n%s%s\n%s}"
(term_to_string b)
level
(indent level)
(st_term_to_string' (indent level) then_)
level
level
level
(indent level)
(st_term_to_string' (indent level) else_)
level
| Tm_Match {sc; brs} ->
sprintf "match (%s) with %s"
(term_to_string sc)
(branches_to_string brs)
| Tm_IntroPure { p } ->
sprintf "introduce pure (\n%s%s)"
(indent level)
(term_to_string' (indent level) p)
| Tm_ElimExists { p } ->
sprintf "elim_exists %s"
(term_to_string p)
| Tm_IntroExists { p; witnesses } ->
sprintf "introduce\n%s%s\n%swith %s"
(indent level)
(term_to_string' (indent level) p)
level
(term_list_to_string " " witnesses)
| Tm_While { invariant; condition; body } ->
sprintf "while (%s)\n%sinvariant %s\n%s{\n%s%s\n%s}"
(st_term_to_string' level condition)
level
(term_to_string invariant)
level
(indent level)
(st_term_to_string' (indent level) body)
level
| Tm_Par { pre1; body1; post1; pre2; body2; post2 } ->
sprintf "par (<%s> (%s) <%s) (<%s> (%s) <%s)"
(term_to_string pre1)
(st_term_to_string' level body1)
(term_to_string post1)
(term_to_string pre2)
(st_term_to_string' level body2)
(term_to_string post2)
| Tm_Rewrite { t1; t2 } ->
sprintf "rewrite %s %s"
(term_to_string t1)
(term_to_string t2)
| Tm_WithLocal { binder; initializer; body } ->
sprintf "let mut %s = %s;\n%s%s"
(binder_to_string binder)
(term_to_string initializer)
level
(st_term_to_string' level body)
| Tm_WithLocalArray { binder; initializer; length; body } ->
sprintf "let mut %s = [| %s; %s |]\n%s%s"
(binder_to_string binder)
(term_to_string initializer)
(term_to_string length)
level
(st_term_to_string' level body)
| Tm_Admit { ctag; u; typ; post } ->
sprintf "%s<%s> %s%s"
(match ctag with
| STT -> "stt_admit"
| STT_Atomic -> "stt_atomic_admit"
| STT_Ghost -> "stt_ghost_admit")
(universe_to_string 0 u)
(term_to_string typ)
(match post with
| None -> ""
| Some post -> sprintf " %s" (term_to_string post))
| Tm_Unreachable -> "unreachable ()"
| Tm_ProofHintWithBinders { binders; hint_type; t} ->
let with_prefix =
match binders with
| [] -> ""
| _ -> sprintf "with %s." (String.concat " " (T.map binder_to_string binders))
in
let names_to_string = function
| None -> ""
| Some l -> sprintf " [%s]" (String.concat "; " l)
in
let ht, p =
match hint_type with
| ASSERT { p } -> "assert", term_to_string p
| UNFOLD { names; p } -> sprintf "unfold%s" (names_to_string names), term_to_string p
| FOLD { names; p } -> sprintf "fold%s" (names_to_string names), term_to_string p
| RENAME { pairs; goal } ->
sprintf "rewrite each %s"
(String.concat ", "
(T.map
(fun (x, y) -> sprintf "%s as %s" (term_to_string x) (term_to_string y))
pairs)),
(match goal with
| None -> ""
| Some t -> sprintf " in %s" (term_to_string t))
| REWRITE { t1; t2 } ->
sprintf "rewrite %s as %s" (term_to_string t1) (term_to_string t2), ""
| WILD -> "_", ""
| SHOW_PROOF_STATE _ -> "show_proof_state", ""
in
sprintf "%s %s %s; %s" with_prefix ht p
(st_term_to_string' level t)
| Tm_WithInv { name; body; returns_inv } ->
sprintf "with_inv %s %s %s"
(term_to_string name)
(st_term_to_string' level body)
(match returns_inv with
| None -> ""
| Some (b, t) ->
sprintf "\nreturns %s\nensures %s"
(binder_to_string b)
(term_to_string t))
and branches_to_string brs : T.Tac _ =
match brs with
| [] -> ""
| b::bs -> branch_to_string b ^ branches_to_string bs
and branch_to_string br : T.Tac _ =
let (pat, e) = br in
Printf.sprintf "{ %s -> %s }"
(pattern_to_string pat)
(st_term_to_string' "" e)
and pattern_to_string (p:pattern) : T.Tac string =
match p with
| Pat_Cons fv pats ->
Printf.sprintf "(%s %s)"
(String.concat "." fv.fv_name)
(String.concat " " (T.map (fun (p, _) -> pattern_to_string p) pats))
| Pat_Constant c ->
"<constant>"
| Pat_Var x _ ->
T.unseal x
| Pat_Dot_Term None ->
""
| Pat_Dot_Term (Some t) ->
Printf.sprintf "(.??)" //%s)" (term_to_string t) | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | t: Pulse.Syntax.Base.st_term -> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Syntax.Base.st_term",
"Pulse.Syntax.Printer.st_term_to_string'",
"Prims.string"
] | [] | false | true | false | false | false | let st_term_to_string t =
| st_term_to_string' "" t | false |
LowParse.SLow.BCVLI.fst | LowParse.SLow.BCVLI.parse32_bounded_bcvli | val parse32_bounded_bcvli
(min: nat)
(min32: U32.t{U32.v min32 == min})
(max: nat{min <= max})
(max32: U32.t{U32.v max32 == max})
: Tot (parser32 (parse_bounded_bcvli min max)) | val parse32_bounded_bcvli
(min: nat)
(min32: U32.t{U32.v min32 == min})
(max: nat{min <= max})
(max32: U32.t{U32.v max32 == max})
: Tot (parser32 (parse_bounded_bcvli min max)) | let parse32_bounded_bcvli
(min: nat)
(min32: U32.t { U32.v min32 == min })
(max: nat { min <= max })
(max32: U32.t { U32.v max32 == max })
: Tot (parser32 (parse_bounded_bcvli min max))
= fun input -> ((
[@inline_let]
let _ = parse_bounded_bcvli_eq min max (B32.reveal input) in
[@inline_let]
let _ = parse_bcvli_eq (B32.reveal input) in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul && min32 `U32.lte` x32 && x32 `U32.lte` max32
then Some (x32, consumed_x)
else if max32 `U32.lt` 253ul
then None
else
if x32 = 253ul
then
if 65536ul `U32.lte` min32
then None
else
let input' = B32.slice input consumed_x (B32.len input) in
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if
y `U32.lt` 253ul || y `U32.lt` min32 || max32 `U32.lt` y
then
None
else
Some (y, consumed_x `U32.add` consumed_y)
else if max32 `U32.lt` 65536ul
then None
else if x32 = 254ul
then
let input' = B32.slice input consumed_x (B32.len input) in
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if
y `U32.lt` 65536ul || y `U32.lt` min32 || max32 `U32.lt` y
then
None
else
Some (y, consumed_x `U32.add` consumed_y)
else
None
) <: (res: _ { parser32_correct (parse_bounded_bcvli min max) input res })) | {
"file_name": "src/lowparse/LowParse.SLow.BCVLI.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 77,
"end_line": 125,
"start_col": 0,
"start_line": 75
} | module LowParse.SLow.BCVLI
include LowParse.Spec.BCVLI
include LowParse.SLow.Combinators // for make_total_constant_size_parser32
include LowParse.SLow.BoundedInt // for bounded_integer_le
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
module Cast = FStar.Int.Cast
#push-options "--max_fuel 0"
let parse32_bcvli
: parser32 parse_bcvli
= fun input -> ((
[@inline_let] let _ =
parse_bcvli_eq (B32.reveal input)
in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul
then Some (x32, consumed_x)
else
let input' = B32.slice input consumed_x (B32.len input) in
if x32 = 253ul
then
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 253ul then None else Some (y, consumed_x `U32.add` consumed_y)
else if x32 = 254ul
then
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 65536ul then None else Some (y, consumed_x `U32.add` consumed_y)
else
None
) <: (res: _ { parser32_correct parse_bcvli input res } ))
module U8 = FStar.UInt8
let serialize32_bcvli
: serializer32 serialize_bcvli
= fun x -> ((
[@inline_let] let _ = serialize_bcvli_eq x in
let c1 : bounded_integer 1 =
if x `U32.lt` 253ul
then x
else if x `U32.lt` 65536ul
then 253ul
else 254ul
in
let s1 = serialize32_bounded_integer_le_1 c1 in
if c1 `U32.lt` 253ul
then s1
else if c1 = 253ul
then s1 `B32.append` serialize32_bounded_integer_le_2 x
else s1 `B32.append` serialize32_bounded_integer_le_4 x
) <: (res: bytes32 { serializer32_correct' serialize_bcvli x res } ))
let size32_bcvli
: size32 serialize_bcvli
= fun x -> ((
[@inline_let] let _ = serialize_bcvli_eq x in
if x `U32.lt` 253ul
then 1ul
else if x `U32.lt` 65536ul
then 3ul
else 5ul
) <: (res: _ { size32_postcond serialize_bcvli x res } )) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.SLow.BoundedInt.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.BCVLI.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.UInt8",
"short_module": "U8"
},
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
min: Prims.nat ->
min32: FStar.UInt32.t{FStar.UInt32.v min32 == min} ->
max: Prims.nat{min <= max} ->
max32: FStar.UInt32.t{FStar.UInt32.v max32 == max}
-> LowParse.SLow.Base.parser32 (LowParse.Spec.BCVLI.parse_bounded_bcvli min max) | Prims.Tot | [
"total"
] | [] | [
"Prims.nat",
"FStar.UInt32.t",
"Prims.eq2",
"Prims.int",
"Prims.l_or",
"FStar.UInt.size",
"FStar.UInt32.n",
"Prims.b2t",
"Prims.op_GreaterThanOrEqual",
"FStar.UInt32.v",
"Prims.op_LessThanOrEqual",
"Prims.l_and",
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le_1",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"LowParse.Spec.BoundedInt.bounded_int32",
"LowParse.Spec.BoundedInt.bounded_integer",
"Prims.op_AmpAmp",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"FStar.UInt32.lte",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Prims.op_Equality",
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le_2",
"Prims.op_BarBar",
"FStar.UInt32.add",
"FStar.Pervasives.Native.option",
"LowParse.SLow.Base.parser32_correct",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bounded_bcvli",
"FStar.Bytes.bytes",
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"FStar.Bytes.reveal",
"FStar.Seq.Base.slice",
"FStar.Bytes.len",
"FStar.Bytes.slice",
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le_4",
"Prims.unit",
"LowParse.Spec.BCVLI.parse_bcvli_eq",
"LowParse.Spec.BCVLI.parse_bounded_bcvli_eq",
"LowParse.SLow.Base.parser32"
] | [] | false | false | false | false | false | let parse32_bounded_bcvli
(min: nat)
(min32: U32.t{U32.v min32 == min})
(max: nat{min <= max})
(max32: U32.t{U32.v max32 == max})
: Tot (parser32 (parse_bounded_bcvli min max)) =
| fun input ->
(([@@ inline_let ]let _ = parse_bounded_bcvli_eq min max (B32.reveal input) in
[@@ inline_let ]let _ = parse_bcvli_eq (B32.reveal input) in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul && min32 `U32.lte` x32 && x32 `U32.lte` max32
then Some (x32, consumed_x)
else
if max32 `U32.lt` 253ul
then None
else
if x32 = 253ul
then
if 65536ul `U32.lte` min32
then None
else
let input' = B32.slice input consumed_x (B32.len input) in
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 253ul || y `U32.lt` min32 || max32 `U32.lt` y
then None
else Some (y, consumed_x `U32.add` consumed_y)
else
if max32 `U32.lt` 65536ul
then None
else
if x32 = 254ul
then
let input' = B32.slice input consumed_x (B32.len input) in
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 65536ul || y `U32.lt` min32 || max32 `U32.lt` y
then None
else Some (y, consumed_x `U32.add` consumed_y)
else None)
<:
(res: _{parser32_correct (parse_bounded_bcvli min max) input res})) | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.index_vecs_to_bytes_be | val index_vecs_to_bytes_be: #vt:v_inttype -> #w:width -> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len -> i:nat{i < len * (numbytes vt * w)} ->
Lemma ((vecs_to_bytes_be #vt #w #len vl).[i] == (vec_to_bytes_be vl.[i / (numbytes vt * w)]).[i % (numbytes vt * w)]) | val index_vecs_to_bytes_be: #vt:v_inttype -> #w:width -> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len -> i:nat{i < len * (numbytes vt * w)} ->
Lemma ((vecs_to_bytes_be #vt #w #len vl).[i] == (vec_to_bytes_be vl.[i / (numbytes vt * w)]).[i % (numbytes vt * w)]) | let index_vecs_to_bytes_be #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_be_f #vt #w #len vl) i | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 84,
"start_col": 0,
"start_line": 82
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i]
let vecs_to_bytes_le #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_le_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_le #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_le_f #vt #w #len vl) i
val vecs_to_bytes_be_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_be_f #vt #w #len vl i () =
(), vec_to_bytes_be vl.[i]
let vecs_to_bytes_be #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_be_f #vt #w #len vl) () in
o | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
vl: Lib.Sequence.lseq (Lib.IntVector.vec_t vt w) len ->
i: Prims.nat{i < len * (Lib.IntTypes.numbytes vt * w)}
-> FStar.Pervasives.Lemma
(ensures
(Lib.IntVector.Serialize.vecs_to_bytes_be vl).[ i ] ==
(Lib.IntVector.vec_to_bytes_be vl.[ i / (Lib.IntTypes.numbytes vt * w) ]).[ i %
(Lib.IntTypes.numbytes vt * w) ]) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Prims.op_LessThan",
"Lib.Sequence.index_generate_blocks",
"Lib.IntTypes.uint8",
"Lib.IntVector.Serialize.vecs_to_bytes_be_f",
"Prims.unit"
] | [] | true | false | true | false | false | let index_vecs_to_bytes_be #vt #w #len vl i =
| index_generate_blocks (numbytes vt * w) len len (vecs_to_bytes_be_f #vt #w #len vl) i | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.decl_to_string | val decl_to_string (d:decl) : T.Tac string | val decl_to_string (d:decl) : T.Tac string | let decl_to_string (d:decl) : T.Tac string =
match d.d with
| FnDecl {id; isrec; bs; body} ->
"fn " ^ (if isrec then "rec " else "") ^
fst (R.inspect_ident id) ^ " " ^
String.concat " " (T.map (fun (_, b, _) -> binder_to_string b) bs) ^
" { " ^ st_term_to_string body ^ "}" | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 42,
"end_line": 538,
"start_col": 0,
"start_line": 532
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>"
let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u)
let qual_to_string = function
| None -> ""
| Some Implicit -> "#"
let indent (level:string) = level ^ "\t"
let rec collect_binders (until: term' -> bool) (t:term) : list binder & term =
if not (until t.t) then [], t
else (
match t.t with
| Tm_ExistsSL _ b body
| Tm_ForallSL _ b body ->
let bs, t = collect_binders until body in
b::bs, t
| _ -> [], t
)
let rec binder_to_string_paren (b:binder)
: T.Tac string
= sprintf "(%s%s:%s)"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string' "" b.binder_ty)
and term_to_string' (level:string) (t:term)
: T.Tac string
= match t.t with
| Tm_Emp -> "emp"
| Tm_Pure p ->
sprintf "pure (%s)"
(term_to_string' (indent level) p)
| Tm_Star p1 p2 ->
sprintf "%s ** \n%s%s"
(term_to_string' level p1)
level
(term_to_string' level p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
sprintf "(exists* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_ForallSL u b body ->
let bs, body = collect_binders Tm_ForallSL? t in
sprintf "(forall* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_VProp -> "vprop"
| Tm_Inames -> "inames"
| Tm_EmpInames -> "emp_inames"
| Tm_Unknown -> "_"
| Tm_AddInv i is ->
sprintf "add_inv %s %s"
(term_to_string' level i)
(term_to_string' level is)
| Tm_Inv i ->
sprintf "inv %s"
(term_to_string' level i)
| Tm_FStar t ->
T.term_to_string t
let term_to_string t = term_to_string' "" t
let rec binder_to_doc b : T.Tac document =
parens (doc_of_string (T.unseal b.binder_ppname.name)
^^ doc_of_string ":"
^^ term_to_doc b.binder_ty)
and term_to_doc t
: T.Tac document
= match t.t with
| Tm_Emp -> doc_of_string "emp"
| Tm_Pure p -> doc_of_string "pure" ^^ parens (term_to_doc p)
| Tm_Star p1 p2 ->
infix 2 1 (doc_of_string "**")
(term_to_doc p1)
(term_to_doc p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
parens (doc_of_string "exists*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_ForallSL _ _ _ ->
let bs, body = collect_binders Tm_ForallSL? t in
parens (doc_of_string "forall*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_VProp -> doc_of_string "vprop"
| Tm_Inames -> doc_of_string "inames"
| Tm_EmpInames -> doc_of_string "emp_inames"
| Tm_AddInv i is ->
doc_of_string "add_inv" ^/^ parens (term_to_doc i ^^ doc_of_string "," ^^ term_to_doc is)
| Tm_Inv i ->
doc_of_string "inv" ^/^ parens (term_to_doc i)
| Tm_Unknown -> doc_of_string "_"
| Tm_FStar t ->
// Should call term_to_doc when available
doc_of_string (T.term_to_string t)
let binder_to_string (b:binder)
: T.Tac string
= sprintf "%s%s:%s"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string b.binder_ty)
let ctag_to_string = function
| STT -> "ST"
| STT_Atomic -> "STAtomic"
| STT_Ghost -> "STGhost"
let observability_to_string =
function
| Observable -> "Observable"
| Unobservable -> "Unobservable"
| Neutral -> "Neutral"
let effect_annot_to_string = function
| EffectAnnotSTT -> "stt"
| EffectAnnotGhost -> "stt_ghost"
| EffectAnnotAtomic { opens } -> sprintf "stt_atomic %s" (term_to_string opens)
let comp_to_string (c:comp)
: T.Tac string
= match c with
| C_Tot t ->
sprintf "Tot %s" (term_to_string t)
| C_ST s ->
sprintf "stt %s (requires\n%s) (ensures\n%s)"
(term_to_string s.res)
(term_to_string s.pre)
(term_to_string s.post)
| C_STAtomic inames obs s ->
sprintf "stt_atomic %s #%s %s (requires\n%s) (ensures\n%s)"
(term_to_string s.res)
(observability_to_string obs)
(term_to_string inames)
(term_to_string s.pre)
(term_to_string s.post)
| C_STGhost s ->
sprintf "stt_ghost %s (requires\n%s) (ensures\n%s)"
(term_to_string s.res)
(term_to_string s.pre)
(term_to_string s.post)
let term_opt_to_string (t:option term)
: T.Tac string
= match t with
| None -> ""
| Some t -> term_to_string t
let term_list_to_string (sep:string) (t:list term)
: T.Tac string
= String.concat sep (T.map term_to_string t)
let rec st_term_to_string' (level:string) (t:st_term)
: T.Tac string
= match t.term with
| Tm_Return { insert_eq; term } ->
sprintf "return_%s %s"
(if insert_eq then "" else "_noeq")
(term_to_string term)
| Tm_STApp {head; arg_qual; arg } ->
sprintf "(%s%s %s%s)"
(if dbg_printing then "<stapp>" else "")
(term_to_string head)
(qual_to_string arg_qual)
(term_to_string arg)
| Tm_Bind { binder; head; body } ->
// if T.unseal binder.binder_ppname.name = "_"
// then sprintf "%s;\n%s%s"
// (st_term_to_string' level head)
// level
// (st_term_to_string' level body)
// else (
sprintf "let %s = %s;\n%s%s"
(binder_to_string binder)
(st_term_to_string' level head)
level
(st_term_to_string' level body)
// )
| Tm_TotBind { head; binder; body } ->
sprintf "let tot %s = %s;\n%s%s"
(binder_to_string binder)
(term_to_string head)
level
(st_term_to_string' level body)
| Tm_Abs { b; q; ascription=c; body } ->
sprintf "(fun (%s%s)\n%s\n ({\n%s%s\n}%s)"
(qual_to_string q)
(binder_to_string b)
(match c.annotated with | None -> "" | Some c -> comp_to_string c)
(indent level)
(st_term_to_string' (indent level) body)
(match c.elaborated with | None -> "" | Some c -> " <: " ^ comp_to_string c)
| Tm_If { b; then_; else_ } ->
sprintf "if (%s)\n%s{\n%s%s\n%s}\n%selse\n%s{\n%s%s\n%s}"
(term_to_string b)
level
(indent level)
(st_term_to_string' (indent level) then_)
level
level
level
(indent level)
(st_term_to_string' (indent level) else_)
level
| Tm_Match {sc; brs} ->
sprintf "match (%s) with %s"
(term_to_string sc)
(branches_to_string brs)
| Tm_IntroPure { p } ->
sprintf "introduce pure (\n%s%s)"
(indent level)
(term_to_string' (indent level) p)
| Tm_ElimExists { p } ->
sprintf "elim_exists %s"
(term_to_string p)
| Tm_IntroExists { p; witnesses } ->
sprintf "introduce\n%s%s\n%swith %s"
(indent level)
(term_to_string' (indent level) p)
level
(term_list_to_string " " witnesses)
| Tm_While { invariant; condition; body } ->
sprintf "while (%s)\n%sinvariant %s\n%s{\n%s%s\n%s}"
(st_term_to_string' level condition)
level
(term_to_string invariant)
level
(indent level)
(st_term_to_string' (indent level) body)
level
| Tm_Par { pre1; body1; post1; pre2; body2; post2 } ->
sprintf "par (<%s> (%s) <%s) (<%s> (%s) <%s)"
(term_to_string pre1)
(st_term_to_string' level body1)
(term_to_string post1)
(term_to_string pre2)
(st_term_to_string' level body2)
(term_to_string post2)
| Tm_Rewrite { t1; t2 } ->
sprintf "rewrite %s %s"
(term_to_string t1)
(term_to_string t2)
| Tm_WithLocal { binder; initializer; body } ->
sprintf "let mut %s = %s;\n%s%s"
(binder_to_string binder)
(term_to_string initializer)
level
(st_term_to_string' level body)
| Tm_WithLocalArray { binder; initializer; length; body } ->
sprintf "let mut %s = [| %s; %s |]\n%s%s"
(binder_to_string binder)
(term_to_string initializer)
(term_to_string length)
level
(st_term_to_string' level body)
| Tm_Admit { ctag; u; typ; post } ->
sprintf "%s<%s> %s%s"
(match ctag with
| STT -> "stt_admit"
| STT_Atomic -> "stt_atomic_admit"
| STT_Ghost -> "stt_ghost_admit")
(universe_to_string 0 u)
(term_to_string typ)
(match post with
| None -> ""
| Some post -> sprintf " %s" (term_to_string post))
| Tm_Unreachable -> "unreachable ()"
| Tm_ProofHintWithBinders { binders; hint_type; t} ->
let with_prefix =
match binders with
| [] -> ""
| _ -> sprintf "with %s." (String.concat " " (T.map binder_to_string binders))
in
let names_to_string = function
| None -> ""
| Some l -> sprintf " [%s]" (String.concat "; " l)
in
let ht, p =
match hint_type with
| ASSERT { p } -> "assert", term_to_string p
| UNFOLD { names; p } -> sprintf "unfold%s" (names_to_string names), term_to_string p
| FOLD { names; p } -> sprintf "fold%s" (names_to_string names), term_to_string p
| RENAME { pairs; goal } ->
sprintf "rewrite each %s"
(String.concat ", "
(T.map
(fun (x, y) -> sprintf "%s as %s" (term_to_string x) (term_to_string y))
pairs)),
(match goal with
| None -> ""
| Some t -> sprintf " in %s" (term_to_string t))
| REWRITE { t1; t2 } ->
sprintf "rewrite %s as %s" (term_to_string t1) (term_to_string t2), ""
| WILD -> "_", ""
| SHOW_PROOF_STATE _ -> "show_proof_state", ""
in
sprintf "%s %s %s; %s" with_prefix ht p
(st_term_to_string' level t)
| Tm_WithInv { name; body; returns_inv } ->
sprintf "with_inv %s %s %s"
(term_to_string name)
(st_term_to_string' level body)
(match returns_inv with
| None -> ""
| Some (b, t) ->
sprintf "\nreturns %s\nensures %s"
(binder_to_string b)
(term_to_string t))
and branches_to_string brs : T.Tac _ =
match brs with
| [] -> ""
| b::bs -> branch_to_string b ^ branches_to_string bs
and branch_to_string br : T.Tac _ =
let (pat, e) = br in
Printf.sprintf "{ %s -> %s }"
(pattern_to_string pat)
(st_term_to_string' "" e)
and pattern_to_string (p:pattern) : T.Tac string =
match p with
| Pat_Cons fv pats ->
Printf.sprintf "(%s %s)"
(String.concat "." fv.fv_name)
(String.concat " " (T.map (fun (p, _) -> pattern_to_string p) pats))
| Pat_Constant c ->
"<constant>"
| Pat_Var x _ ->
T.unseal x
| Pat_Dot_Term None ->
""
| Pat_Dot_Term (Some t) ->
Printf.sprintf "(.??)" //%s)" (term_to_string t)
let st_term_to_string t = st_term_to_string' "" t
let tag_of_term (t:term) =
match t.t with
| Tm_Emp -> "Tm_Emp"
| Tm_Pure _ -> "Tm_Pure"
| Tm_Star _ _ -> "Tm_Star"
| Tm_ExistsSL _ _ _ -> "Tm_ExistsSL"
| Tm_ForallSL _ _ _ -> "Tm_ForallSL"
| Tm_VProp -> "Tm_VProp"
| Tm_Inames -> "Tm_Inames"
| Tm_EmpInames -> "Tm_EmpInames"
| Tm_Unknown -> "Tm_Unknown"
| Tm_FStar _ -> "Tm_FStar"
| Tm_AddInv _ _ -> "Tm_AddInv"
| Tm_Inv _ -> "Tm_Inv"
let tag_of_st_term (t:st_term) =
match t.term with
| Tm_Return _ -> "Tm_Return"
| Tm_Abs _ -> "Tm_Abs"
| Tm_STApp _ -> "Tm_STApp"
| Tm_Bind _ -> "Tm_Bind"
| Tm_TotBind _ -> "Tm_TotBind"
| Tm_If _ -> "Tm_If"
| Tm_Match _ -> "Tm_Match"
| Tm_IntroPure _ -> "Tm_IntroPure"
| Tm_ElimExists _ -> "Tm_ElimExists"
| Tm_IntroExists _ -> "Tm_IntroExists"
| Tm_While _ -> "Tm_While"
| Tm_Par _ -> "Tm_Par"
| Tm_WithLocal _ -> "Tm_WithLocal"
| Tm_WithLocalArray _ -> "Tm_WithLocalArray"
| Tm_Rewrite _ -> "Tm_Rewrite"
| Tm_Admit _ -> "Tm_Admit"
| Tm_Unreachable -> "Tm_Unreachable"
| Tm_ProofHintWithBinders _ -> "Tm_ProofHintWithBinders"
| Tm_WithInv _ -> "Tm_WithInv"
let tag_of_comp (c:comp) : T.Tac string =
match c with
| C_Tot _ -> "Total"
| C_ST _ -> "ST"
| C_STAtomic i obs _ ->
Printf.sprintf "%s %s" (observability_to_string obs) (term_to_string i)
| C_STGhost _ ->
"Ghost"
let rec print_st_head (t:st_term)
: Tot string (decreases t) =
match t.term with
| Tm_Abs _ -> "Abs"
| Tm_Return p -> print_head p.term
| Tm_Bind _ -> "Bind"
| Tm_TotBind _ -> "TotBind"
| Tm_If _ -> "If"
| Tm_Match _ -> "Match"
| Tm_While _ -> "While"
| Tm_Admit _ -> "Admit"
| Tm_Unreachable -> "Unreachable"
| Tm_Par _ -> "Par"
| Tm_Rewrite _ -> "Rewrite"
| Tm_WithLocal _ -> "WithLocal"
| Tm_WithLocalArray _ -> "WithLocalArray"
| Tm_STApp { head = p } -> print_head p
| Tm_IntroPure _ -> "IntroPure"
| Tm_IntroExists _ -> "IntroExists"
| Tm_ElimExists _ -> "ElimExists"
| Tm_ProofHintWithBinders _ -> "AssertWithBinders"
| Tm_WithInv _ -> "WithInv"
and print_head (t:term) =
match t with
// | Tm_FVar fv
// | Tm_UInst fv _ -> String.concat "." fv.fv_name
// | Tm_PureApp head _ _ -> print_head head
| _ -> "<pure term>"
let rec print_skel (t:st_term) =
match t.term with
| Tm_Abs { body } -> Printf.sprintf "(fun _ -> %s)" (print_skel body)
| Tm_Return { term = p } -> print_head p
| Tm_Bind { head=e1; body=e2 } -> Printf.sprintf "(Bind %s %s)" (print_skel e1) (print_skel e2)
| Tm_TotBind { body=e2 } -> Printf.sprintf "(TotBind _ %s)" (print_skel e2)
| Tm_If _ -> "If"
| Tm_Match _ -> "Match"
| Tm_While _ -> "While"
| Tm_Admit _ -> "Admit"
| Tm_Unreachable -> "Unreachable"
| Tm_Par _ -> "Par"
| Tm_Rewrite _ -> "Rewrite"
| Tm_WithLocal _ -> "WithLocal"
| Tm_WithLocalArray _ -> "WithLocalArray"
| Tm_STApp { head = p } -> print_head p
| Tm_IntroPure _ -> "IntroPure"
| Tm_IntroExists _ -> "IntroExists"
| Tm_ElimExists _ -> "ElimExists"
| Tm_ProofHintWithBinders _ -> "AssertWithBinders"
| Tm_WithInv _ -> "WithInv" | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | d: Pulse.Syntax.Base.decl -> FStar.Tactics.Effect.Tac Prims.string | FStar.Tactics.Effect.Tac | [] | [] | [
"Pulse.Syntax.Base.decl",
"Pulse.Syntax.Base.__proj__Mkdecl__item__d",
"FStar.Stubs.Reflection.Types.ident",
"Prims.bool",
"Prims.list",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.option",
"Pulse.Syntax.Base.qualifier",
"Pulse.Syntax.Base.binder",
"Pulse.Syntax.Base.bv",
"Pulse.Syntax.Base.comp",
"Pulse.Syntax.Base.term",
"Prims.l_imp",
"Prims.b2t",
"FStar.Pervasives.Native.uu___is_Some",
"Pulse.Syntax.Base.st_term",
"Prims.op_Hat",
"Prims.string",
"FStar.Pervasives.Native.fst",
"FStar.Range.range",
"FStar.Stubs.Reflection.V2.Builtins.inspect_ident",
"Pulse.Syntax.Printer.st_term_to_string",
"FStar.String.concat",
"FStar.Tactics.Util.map",
"Pulse.Syntax.Printer.binder_to_string"
] | [] | false | true | false | false | false | let decl_to_string (d: decl) : T.Tac string =
| match d.d with
| FnDecl { id = id ; isrec = isrec ; bs = bs ; body = body } ->
"fn " ^
(if isrec then "rec " else "") ^
fst (R.inspect_ident id) ^
" " ^
String.concat " " (T.map (fun (_, b, _) -> binder_to_string b) bs) ^
" { " ^ st_term_to_string body ^ "}" | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_load_be | val vecs_load_be:
#vt:v_inttype
-> #w:width
-> #len:size_t{v len * (numbytes vt * w) <= max_size_t}
-> o:lbuffer (vec_t vt w) len
-> i:lbuffer uint8 (len *! (size (numbytes vt) *! size w)) ->
Stack unit
(requires fun h -> live h i /\ live h o /\ B.disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == vecs_from_bytes_be vt w (v len) (as_seq h0 i)) | val vecs_load_be:
#vt:v_inttype
-> #w:width
-> #len:size_t{v len * (numbytes vt * w) <= max_size_t}
-> o:lbuffer (vec_t vt w) len
-> i:lbuffer uint8 (len *! (size (numbytes vt) *! size w)) ->
Stack unit
(requires fun h -> live h i /\ live h o /\ B.disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == vecs_from_bytes_be vt w (v len) (as_seq h0 i)) | let vecs_load_be #vt #w #len o i =
let h0 = ST.get () in
fill h0 len o
(fun h -> vecs_from_bytes_be_f vt w (v len) (as_seq h i))
(fun j ->
let h = ST.get () in
let bj = sub i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w) in
let r = vec_load_be vt w bj in
as_seq_gsub h i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w);
r);
let h1 = ST.get () in
eq_intro (as_seq h1 o) (vecs_from_bytes_be vt w (v len) (as_seq h0 i)) | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 72,
"end_line": 112,
"start_col": 0,
"start_line": 101
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i]
let vecs_to_bytes_le #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_le_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_le #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_le_f #vt #w #len vl) i
val vecs_to_bytes_be_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_be_f #vt #w #len vl i () =
(), vec_to_bytes_be vl.[i]
let vecs_to_bytes_be #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_be_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_be #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_be_f #vt #w #len vl) i
let vecs_load_le #vt #w #len o i =
let h0 = ST.get () in
fill h0 len o
(fun h -> vecs_from_bytes_le_f vt w (v len) (as_seq h i))
(fun j ->
let h = ST.get () in
let bj = sub i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w) in
let r = vec_load_le vt w bj in
as_seq_gsub h i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w);
r);
let h1 = ST.get () in
eq_intro (as_seq h1 o) (vecs_from_bytes_le vt w (v len) (as_seq h0 i)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
o: Lib.Buffer.lbuffer (Lib.IntVector.vec_t vt w) len ->
i:
Lib.Buffer.lbuffer Lib.IntTypes.uint8
(len *! (Lib.IntTypes.size (Lib.IntTypes.numbytes vt) *! Lib.IntTypes.size w))
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntVector.vec_t",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size",
"Lib.Sequence.eq_intro",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntVector.Serialize.vecs_from_bytes_be",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.fill",
"Lib.IntVector.Serialize.vecs_from_bytes_be_f",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"Lib.Buffer.as_seq_gsub",
"Lib.IntVector.vec_load_be",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub"
] | [] | false | true | false | false | false | let vecs_load_be #vt #w #len o i =
| let h0 = ST.get () in
fill h0
len
o
(fun h -> vecs_from_bytes_be_f vt w (v len) (as_seq h i))
(fun j ->
let h = ST.get () in
let bj = sub i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w) in
let r = vec_load_be vt w bj in
as_seq_gsub h i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w);
r);
let h1 = ST.get () in
eq_intro (as_seq h1 o) (vecs_from_bytes_be vt w (v len) (as_seq h0 i)) | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.tot_or_ghost_to_string | val tot_or_ghost_to_string (eff:T.tot_or_ghost) : string | val tot_or_ghost_to_string (eff:T.tot_or_ghost) : string | let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost" | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 24,
"end_line": 29,
"start_col": 0,
"start_line": 27
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2 | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | eff: FStar.Stubs.TypeChecker.Core.tot_or_ghost -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"FStar.Stubs.TypeChecker.Core.tot_or_ghost",
"Prims.string"
] | [] | false | false | false | true | false | let tot_or_ghost_to_string =
| function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost" | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_store_be | val vecs_store_be:
#vt:v_inttype
-> #w:width
-> #len:size_t{v len * (numbytes vt * w) <= max_size_t}
-> o:lbuffer uint8 (len *! (size (numbytes vt) *! size w))
-> i:lbuffer (vec_t vt w) len ->
Stack unit
(requires fun h -> live h i /\ live h o /\ B.disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == vecs_to_bytes_be #vt #w #(v len) (as_seq h0 i)) | val vecs_store_be:
#vt:v_inttype
-> #w:width
-> #len:size_t{v len * (numbytes vt * w) <= max_size_t}
-> o:lbuffer uint8 (len *! (size (numbytes vt) *! size w))
-> i:lbuffer (vec_t vt w) len ->
Stack unit
(requires fun h -> live h i /\ live h o /\ B.disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == vecs_to_bytes_be #vt #w #(v len) (as_seq h0 i)) | let vecs_store_be #vt #w #len o i =
let h0 = ST.get () in
[@ inline_let]
let a_spec (i:nat{i <= v len}) = unit in
fill_blocks h0 (size (numbytes vt) *! size w) len o a_spec
(fun _ _ -> ())
(fun _ -> LowStar.Buffer.loc_none)
(fun h -> vecs_to_bytes_be_f (as_seq h i))
(fun j -> vec_store_be (sub o (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w)) i.(j));
norm_spec [delta_only [`%vecs_to_bytes_be]] (vecs_to_bytes_be (as_seq h0 i)) | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 142,
"start_col": 0,
"start_line": 131
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i]
let vecs_to_bytes_le #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_le_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_le #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_le_f #vt #w #len vl) i
val vecs_to_bytes_be_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_be_f #vt #w #len vl i () =
(), vec_to_bytes_be vl.[i]
let vecs_to_bytes_be #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_be_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_be #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_be_f #vt #w #len vl) i
let vecs_load_le #vt #w #len o i =
let h0 = ST.get () in
fill h0 len o
(fun h -> vecs_from_bytes_le_f vt w (v len) (as_seq h i))
(fun j ->
let h = ST.get () in
let bj = sub i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w) in
let r = vec_load_le vt w bj in
as_seq_gsub h i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w);
r);
let h1 = ST.get () in
eq_intro (as_seq h1 o) (vecs_from_bytes_le vt w (v len) (as_seq h0 i))
let vecs_load_be #vt #w #len o i =
let h0 = ST.get () in
fill h0 len o
(fun h -> vecs_from_bytes_be_f vt w (v len) (as_seq h i))
(fun j ->
let h = ST.get () in
let bj = sub i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w) in
let r = vec_load_be vt w bj in
as_seq_gsub h i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w);
r);
let h1 = ST.get () in
eq_intro (as_seq h1 o) (vecs_from_bytes_be vt w (v len) (as_seq h0 i))
#set-options "--z3rlimit 100"
let vecs_store_le #vt #w #len o i =
let h0 = ST.get () in
[@ inline_let]
let a_spec (i:nat{i <= v len}) = unit in
fill_blocks h0 (size (numbytes vt) *! size w) len o a_spec
(fun _ _ -> ())
(fun _ -> LowStar.Buffer.loc_none)
(fun h -> vecs_to_bytes_le_f (as_seq h i))
(fun j -> vec_store_le (sub o (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w)) i.(j));
norm_spec [delta_only [`%vecs_to_bytes_le]] (vecs_to_bytes_le (as_seq h0 i)) | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
o:
Lib.Buffer.lbuffer Lib.IntTypes.uint8
(len *! (Lib.IntTypes.size (Lib.IntTypes.numbytes vt) *! Lib.IntTypes.size w)) ->
i: Lib.Buffer.lbuffer (Lib.IntVector.vec_t vt w) len
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size",
"Lib.IntVector.vec_t",
"FStar.Pervasives.norm_spec",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_only",
"Prims.string",
"Prims.Nil",
"Lib.Sequence.lseq",
"Lib.IntVector.Serialize.vecs_to_bytes_be",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.Buffer.fill_blocks",
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_nat",
"LowStar.Monotonic.Buffer.loc_none",
"LowStar.Monotonic.Buffer.loc",
"Prims.l_and",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Lib.Buffer.loc",
"LowStar.Monotonic.Buffer.loc_includes",
"LowStar.Monotonic.Buffer.address_liveness_insensitive_locs",
"Lib.IntVector.Serialize.vecs_to_bytes_be_f",
"Prims.op_LessThan",
"FStar.Pervasives.Native.tuple2",
"Prims.op_Addition",
"Lib.IntVector.vec_store_be",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub",
"Prims.nat",
"Prims.eqtype",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let vecs_store_be #vt #w #len o i =
| let h0 = ST.get () in
[@@ inline_let ]let a_spec (i: nat{i <= v len}) = unit in
fill_blocks h0
(size (numbytes vt) *! size w)
len
o
a_spec
(fun _ _ -> ())
(fun _ -> LowStar.Buffer.loc_none)
(fun h -> vecs_to_bytes_be_f (as_seq h i))
(fun j ->
vec_store_be (sub o (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w))
i.(j));
norm_spec [delta_only [`%vecs_to_bytes_be]] (vecs_to_bytes_be (as_seq h0 i)) | false |
LowParse.SLow.BCVLI.fst | LowParse.SLow.BCVLI.parse32_bcvli | val parse32_bcvli:parser32 parse_bcvli | val parse32_bcvli:parser32 parse_bcvli | let parse32_bcvli
: parser32 parse_bcvli
= fun input -> ((
[@inline_let] let _ =
parse_bcvli_eq (B32.reveal input)
in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul
then Some (x32, consumed_x)
else
let input' = B32.slice input consumed_x (B32.len input) in
if x32 = 253ul
then
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 253ul then None else Some (y, consumed_x `U32.add` consumed_y)
else if x32 = 254ul
then
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 65536ul then None else Some (y, consumed_x `U32.add` consumed_y)
else
None
) <: (res: _ { parser32_correct parse_bcvli input res } )) | {
"file_name": "src/lowparse/LowParse.SLow.BCVLI.fst",
"git_rev": "00217c4a89f5ba56002ba9aa5b4a9d5903bfe9fa",
"git_url": "https://github.com/project-everest/everparse.git",
"project_name": "everparse"
} | {
"end_col": 60,
"end_line": 40,
"start_col": 0,
"start_line": 13
} | module LowParse.SLow.BCVLI
include LowParse.Spec.BCVLI
include LowParse.SLow.Combinators // for make_total_constant_size_parser32
include LowParse.SLow.BoundedInt // for bounded_integer_le
module B32 = LowParse.Bytes32
module Seq = FStar.Seq
module U32 = FStar.UInt32
module Cast = FStar.Int.Cast
#push-options "--max_fuel 0" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowParse.Spec.BCVLI.fsti.checked",
"LowParse.SLow.Combinators.fst.checked",
"LowParse.SLow.BoundedInt.fsti.checked",
"LowParse.Bytes32.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Seq.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Int.Cast.fst.checked"
],
"interface_file": false,
"source_file": "LowParse.SLow.BCVLI.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Int.Cast",
"short_module": "Cast"
},
{
"abbrev": true,
"full_module": "FStar.UInt32",
"short_module": "U32"
},
{
"abbrev": true,
"full_module": "FStar.Seq",
"short_module": "Seq"
},
{
"abbrev": true,
"full_module": "LowParse.Bytes32",
"short_module": "B32"
},
{
"abbrev": false,
"full_module": "LowParse.SLow.BoundedInt",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow.Combinators",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.Spec.BCVLI",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": false,
"full_module": "LowParse.SLow",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 2,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": true,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 5,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | LowParse.SLow.Base.parser32 LowParse.Spec.BCVLI.parse_bcvli | Prims.Tot | [
"total"
] | [] | [
"LowParse.SLow.Base.bytes32",
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le_1",
"FStar.Pervasives.Native.None",
"FStar.Pervasives.Native.tuple2",
"FStar.UInt32.t",
"LowParse.Spec.BoundedInt.bounded_integer",
"FStar.UInt32.lt",
"FStar.UInt32.__uint_to_t",
"FStar.Pervasives.Native.Some",
"FStar.Pervasives.Native.Mktuple2",
"Prims.bool",
"Prims.op_Equality",
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le_2",
"FStar.UInt32.add",
"FStar.Pervasives.Native.option",
"LowParse.SLow.Base.parser32_correct",
"LowParse.Spec.BCVLI.parse_bcvli_kind",
"LowParse.Spec.BCVLI.parse_bcvli",
"LowParse.SLow.BoundedInt.parse32_bounded_integer_le_4",
"FStar.Bytes.bytes",
"Prims.eq2",
"FStar.Seq.Base.seq",
"FStar.UInt8.t",
"FStar.Bytes.reveal",
"FStar.Seq.Base.slice",
"FStar.UInt32.v",
"FStar.Bytes.len",
"FStar.Bytes.slice",
"Prims.unit",
"LowParse.Spec.BCVLI.parse_bcvli_eq"
] | [] | false | false | false | true | false | let parse32_bcvli:parser32 parse_bcvli =
| fun input ->
(([@@ inline_let ]let _ = parse_bcvli_eq (B32.reveal input) in
match parse32_bounded_integer_le_1 input with
| None -> None
| Some (x32, consumed_x) ->
if x32 `U32.lt` 253ul
then Some (x32, consumed_x)
else
let input' = B32.slice input consumed_x (B32.len input) in
if x32 = 253ul
then
match parse32_bounded_integer_le_2 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 253ul then None else Some (y, consumed_x `U32.add` consumed_y)
else
if x32 = 254ul
then
match parse32_bounded_integer_le_4 input' with
| None -> None
| Some (y, consumed_y) ->
if y `U32.lt` 65536ul then None else Some (y, consumed_x `U32.add` consumed_y)
else None)
<:
(res: _{parser32_correct parse_bcvli input res})) | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.qual_to_string | val qual_to_string (q:option qualifier) : string | val qual_to_string (q:option qualifier) : string | let qual_to_string = function
| None -> ""
| Some Implicit -> "#" | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 24,
"end_line": 59,
"start_col": 0,
"start_line": 57
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>" | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | q: FStar.Pervasives.Native.option Pulse.Syntax.Base.qualifier -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"FStar.Pervasives.Native.option",
"Pulse.Syntax.Base.qualifier",
"Prims.string"
] | [] | false | false | false | true | false | let qual_to_string =
| function
| None -> ""
| Some Implicit -> "#" | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.index_vecs_to_bytes_le | val index_vecs_to_bytes_le: #vt:v_inttype -> #w:width -> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len -> i:nat{i < len * (numbytes vt * w)} ->
Lemma ((vecs_to_bytes_le #vt #w #len vl).[i] == (vec_to_bytes_le vl.[i / (numbytes vt * w)]).[i % (numbytes vt * w)]) | val index_vecs_to_bytes_le: #vt:v_inttype -> #w:width -> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len -> i:nat{i < len * (numbytes vt * w)} ->
Lemma ((vecs_to_bytes_le #vt #w #len vl).[i] == (vec_to_bytes_le vl.[i / (numbytes vt * w)]).[i % (numbytes vt * w)]) | let index_vecs_to_bytes_le #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_le_f #vt #w #len vl) i | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 41,
"end_line": 61,
"start_col": 0,
"start_line": 59
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i]
let vecs_to_bytes_le #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_le_f #vt #w #len vl) () in
o | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
vl: Lib.Sequence.lseq (Lib.IntVector.vec_t vt w) len ->
i: Prims.nat{i < len * (Lib.IntTypes.numbytes vt * w)}
-> FStar.Pervasives.Lemma
(ensures
(Lib.IntVector.Serialize.vecs_to_bytes_le vl).[ i ] ==
(Lib.IntVector.vec_to_bytes_le vl.[ i / (Lib.IntTypes.numbytes vt * w) ]).[ i %
(Lib.IntTypes.numbytes vt * w) ]) | FStar.Pervasives.Lemma | [
"lemma"
] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Prims.nat",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Sequence.lseq",
"Lib.IntVector.vec_t",
"Prims.op_LessThan",
"Lib.Sequence.index_generate_blocks",
"Lib.IntTypes.uint8",
"Lib.IntVector.Serialize.vecs_to_bytes_le_f",
"Prims.unit"
] | [] | true | false | true | false | false | let index_vecs_to_bytes_le #vt #w #len vl i =
| index_generate_blocks (numbytes vt * w) len len (vecs_to_bytes_le_f #vt #w #len vl) i | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_load_le | val vecs_load_le:
#vt:v_inttype
-> #w:width
-> #len:size_t{v len * (numbytes vt * w) <= max_size_t}
-> o:lbuffer (vec_t vt w) len
-> i:lbuffer uint8 (len *! (size (numbytes vt) *! size w)) ->
Stack unit
(requires fun h -> live h i /\ live h o /\ B.disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == vecs_from_bytes_le vt w (v len) (as_seq h0 i)) | val vecs_load_le:
#vt:v_inttype
-> #w:width
-> #len:size_t{v len * (numbytes vt * w) <= max_size_t}
-> o:lbuffer (vec_t vt w) len
-> i:lbuffer uint8 (len *! (size (numbytes vt) *! size w)) ->
Stack unit
(requires fun h -> live h i /\ live h o /\ B.disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == vecs_from_bytes_le vt w (v len) (as_seq h0 i)) | let vecs_load_le #vt #w #len o i =
let h0 = ST.get () in
fill h0 len o
(fun h -> vecs_from_bytes_le_f vt w (v len) (as_seq h i))
(fun j ->
let h = ST.get () in
let bj = sub i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w) in
let r = vec_load_le vt w bj in
as_seq_gsub h i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w);
r);
let h1 = ST.get () in
eq_intro (as_seq h1 o) (vecs_from_bytes_le vt w (v len) (as_seq h0 i)) | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 72,
"end_line": 98,
"start_col": 0,
"start_line": 87
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i]
let vecs_to_bytes_le #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_le_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_le #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_le_f #vt #w #len vl) i
val vecs_to_bytes_be_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_be_f #vt #w #len vl i () =
(), vec_to_bytes_be vl.[i]
let vecs_to_bytes_be #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_be_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_be #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_be_f #vt #w #len vl) i | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
o: Lib.Buffer.lbuffer (Lib.IntVector.vec_t vt w) len ->
i:
Lib.Buffer.lbuffer Lib.IntTypes.uint8
(len *! (Lib.IntTypes.size (Lib.IntTypes.numbytes vt) *! Lib.IntTypes.size w))
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntVector.vec_t",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size",
"Lib.Sequence.eq_intro",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Lib.IntVector.Serialize.vecs_from_bytes_le",
"Prims.unit",
"FStar.Monotonic.HyperStack.mem",
"FStar.HyperStack.ST.get",
"Lib.Buffer.fill",
"Lib.IntVector.Serialize.vecs_from_bytes_le_f",
"Lib.IntTypes.size_nat",
"Prims.op_LessThan",
"Lib.Buffer.as_seq_gsub",
"Lib.IntVector.vec_load_le",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub"
] | [] | false | true | false | false | false | let vecs_load_le #vt #w #len o i =
| let h0 = ST.get () in
fill h0
len
o
(fun h -> vecs_from_bytes_le_f vt w (v len) (as_seq h i))
(fun j ->
let h = ST.get () in
let bj = sub i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w) in
let r = vec_load_le vt w bj in
as_seq_gsub h i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w);
r);
let h1 = ST.get () in
eq_intro (as_seq h1 o) (vecs_from_bytes_le vt w (v len) (as_seq h0 i)) | false |
Hacl.Impl.P256.PointAdd.fst | Hacl.Impl.P256.PointAdd.point_add_4 | val point_add_4 (x3 y3 z3 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t1; loc t2 ] /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\ as_nat h y3 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\ as_nat h1 z3 < S.prime /\
(let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let z3_s = S.fmul S.b_coeff t2_s in
let x3_s = S.fsub y3_s z3_s in
let z3_s = S.fadd x3_s x3_s in
let x3_s = S.fadd x3_s z3_s in
let z3_s = S.fsub t1_s x3_s in
let x3_s = S.fadd t1_s x3_s in
let y3_s = S.fmul S.b_coeff y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\ fmont_as_nat h1 z3 == z3_s)) | val point_add_4 (x3 y3 z3 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t1; loc t2 ] /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\ as_nat h y3 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\ as_nat h1 z3 < S.prime /\
(let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let z3_s = S.fmul S.b_coeff t2_s in
let x3_s = S.fsub y3_s z3_s in
let z3_s = S.fadd x3_s x3_s in
let x3_s = S.fadd x3_s z3_s in
let z3_s = S.fsub t1_s x3_s in
let x3_s = S.fadd t1_s x3_s in
let y3_s = S.fmul S.b_coeff y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\ fmont_as_nat h1 z3 == z3_s)) | let point_add_4 x3 y3 z3 t1 t2 =
fmul_by_b_coeff z3 t2;
fsub x3 y3 z3;
fdouble z3 x3;
fadd x3 x3 z3;
fsub z3 t1 x3;
fadd x3 t1 x3;
fmul_by_b_coeff y3 y3 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 23,
"end_line": 163,
"start_col": 0,
"start_line": 156
} | module Hacl.Impl.P256.PointAdd
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
module S = Spec.P256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s))
let point_add_1 t0 t1 t2 t3 t4 p q =
let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
fmul t0 x1 x2;
fmul t1 y1 y2;
fmul t2 z1 z2;
fadd t3 x1 y1;
fadd t4 x2 y2;
fmul t3 t3 t4;
fadd t4 t0 t1
inline_for_extraction noextract
val point_add_2 (t1 t2 t3 t4 t5:felem) (p q:point) : Stack unit
(requires fun h ->
live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\ live h t5 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc t1; loc t2; loc t3; loc t4; loc t5 ] /\
eq_or_disjoint p q /\ disjoint p t1 /\ disjoint p t2 /\
disjoint p t3 /\ disjoint p t4 /\ disjoint p t5 /\
disjoint q t1 /\ disjoint q t2 /\ disjoint q t3 /\
disjoint q t4 /\ disjoint q t5 /\
point_inv h p /\ point_inv h q /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc t3 |+| loc t4 |+| loc t5) h0 h1 /\
as_nat h1 t3 < S.prime /\ as_nat h1 t4 < S.prime /\ as_nat h1 t5 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let t3_s = S.fsub t3_s t4_s in
let t4_s = S.fadd y1 z1 in
let t5_s = S.fadd y2 z2 in
let t4_s = S.fmul t4_s t5_s in
let t5_s = S.fadd t1_s t2_s in
let t4_s = S.fsub t4_s t5_s in
fmont_as_nat h1 t3 == t3_s /\ fmont_as_nat h1 t4 == t4_s /\
fmont_as_nat h1 t5 == t5_s))
let point_add_2 t1 t2 t3 t4 t5 p q =
let y1, z1 = gety p, getz p in
let y2, z2 = gety q, getz q in
fsub t3 t3 t4;
fadd t4 y1 z1;
fadd t5 y2 z2;
fmul t4 t4 t5;
fadd t5 t1 t2;
fsub t4 t4 t5
inline_for_extraction noextract
val point_add_3 (x3 y3 t0 t2:felem) (p q:point) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h t0 /\ live h t2 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc t0; loc t2 ] /\
eq_or_disjoint p q /\ disjoint p x3 /\ disjoint p y3 /\
disjoint p t0 /\ disjoint p t2 /\ disjoint q x3 /\
disjoint q y3 /\ disjoint q t0 /\ disjoint q t2 /\
point_inv h p /\ point_inv h q /\
as_nat h t0 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = fmont_as_nat h0 t0 in
let t2_s = fmont_as_nat h0 t2 in
let x3_s = S.fadd x1 z1 in
let y3_s = S.fadd x2 z2 in
let x3_s = S.fmul x3_s y3_s in
let y3_s = S.fadd t0_s t2_s in
let y3_s = S.fsub x3_s y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_3 x3 y3 t0 t2 p q =
let x1, z1 = getx p, getz p in
let x2, z2 = getx q, getz q in
fadd x3 x1 z1;
fadd y3 x2 z2;
fmul x3 x3 y3;
fadd y3 t0 t2;
fsub y3 x3 y3
inline_for_extraction noextract
val point_add_4 (x3 y3 z3 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t1; loc t2 ] /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\ as_nat h y3 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\ as_nat h1 z3 < S.prime /\
(let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let z3_s = S.fmul S.b_coeff t2_s in
let x3_s = S.fsub y3_s z3_s in
let z3_s = S.fadd x3_s x3_s in
let x3_s = S.fadd x3_s z3_s in
let z3_s = S.fsub t1_s x3_s in
let x3_s = S.fadd t1_s x3_s in
let y3_s = S.fmul S.b_coeff y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\ fmont_as_nat h1 z3 == z3_s)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.PointAdd.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x3: Hacl.Impl.P256.Bignum.felem ->
y3: Hacl.Impl.P256.Bignum.felem ->
z3: Hacl.Impl.P256.Bignum.felem ->
t1: Hacl.Impl.P256.Bignum.felem ->
t2: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Field.fmul_by_b_coeff",
"Prims.unit",
"Hacl.Impl.P256.Field.fadd",
"Hacl.Impl.P256.Field.fsub",
"Hacl.Impl.P256.Field.fdouble"
] | [] | false | true | false | false | false | let point_add_4 x3 y3 z3 t1 t2 =
| fmul_by_b_coeff z3 t2;
fsub x3 y3 z3;
fdouble z3 x3;
fadd x3 x3 z3;
fsub z3 t1 x3;
fadd x3 t1 x3;
fmul_by_b_coeff y3 y3 | false |
Hacl.Impl.P256.PointAdd.fst | Hacl.Impl.P256.PointAdd.point_add_5 | val point_add_5 (x3 y3 z3 t0 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t1 < S.prime /\ as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let t1_s = S.fadd t2_s t2_s in
let t2_s = S.fadd t1_s t2_s in
let y3_s = S.fsub y3_s t2_s in
let y3_s = S.fsub y3_s t0_s in
let t1_s = S.fadd y3_s y3_s in
fmont_as_nat h1 t1 == t1_s /\ fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s)) | val point_add_5 (x3 y3 z3 t0 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t1 < S.prime /\ as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let t1_s = S.fadd t2_s t2_s in
let t2_s = S.fadd t1_s t2_s in
let y3_s = S.fsub y3_s t2_s in
let y3_s = S.fsub y3_s t0_s in
let t1_s = S.fadd y3_s y3_s in
fmont_as_nat h1 t1 == t1_s /\ fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s)) | let point_add_5 x3 y3 z3 t0 t1 t2 =
fdouble t1 t2;
fadd t2 t1 t2;
fsub y3 y3 t2;
fsub y3 y3 t0;
fdouble t1 y3 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 192,
"start_col": 0,
"start_line": 187
} | module Hacl.Impl.P256.PointAdd
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
module S = Spec.P256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s))
let point_add_1 t0 t1 t2 t3 t4 p q =
let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
fmul t0 x1 x2;
fmul t1 y1 y2;
fmul t2 z1 z2;
fadd t3 x1 y1;
fadd t4 x2 y2;
fmul t3 t3 t4;
fadd t4 t0 t1
inline_for_extraction noextract
val point_add_2 (t1 t2 t3 t4 t5:felem) (p q:point) : Stack unit
(requires fun h ->
live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\ live h t5 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc t1; loc t2; loc t3; loc t4; loc t5 ] /\
eq_or_disjoint p q /\ disjoint p t1 /\ disjoint p t2 /\
disjoint p t3 /\ disjoint p t4 /\ disjoint p t5 /\
disjoint q t1 /\ disjoint q t2 /\ disjoint q t3 /\
disjoint q t4 /\ disjoint q t5 /\
point_inv h p /\ point_inv h q /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc t3 |+| loc t4 |+| loc t5) h0 h1 /\
as_nat h1 t3 < S.prime /\ as_nat h1 t4 < S.prime /\ as_nat h1 t5 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let t3_s = S.fsub t3_s t4_s in
let t4_s = S.fadd y1 z1 in
let t5_s = S.fadd y2 z2 in
let t4_s = S.fmul t4_s t5_s in
let t5_s = S.fadd t1_s t2_s in
let t4_s = S.fsub t4_s t5_s in
fmont_as_nat h1 t3 == t3_s /\ fmont_as_nat h1 t4 == t4_s /\
fmont_as_nat h1 t5 == t5_s))
let point_add_2 t1 t2 t3 t4 t5 p q =
let y1, z1 = gety p, getz p in
let y2, z2 = gety q, getz q in
fsub t3 t3 t4;
fadd t4 y1 z1;
fadd t5 y2 z2;
fmul t4 t4 t5;
fadd t5 t1 t2;
fsub t4 t4 t5
inline_for_extraction noextract
val point_add_3 (x3 y3 t0 t2:felem) (p q:point) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h t0 /\ live h t2 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc t0; loc t2 ] /\
eq_or_disjoint p q /\ disjoint p x3 /\ disjoint p y3 /\
disjoint p t0 /\ disjoint p t2 /\ disjoint q x3 /\
disjoint q y3 /\ disjoint q t0 /\ disjoint q t2 /\
point_inv h p /\ point_inv h q /\
as_nat h t0 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = fmont_as_nat h0 t0 in
let t2_s = fmont_as_nat h0 t2 in
let x3_s = S.fadd x1 z1 in
let y3_s = S.fadd x2 z2 in
let x3_s = S.fmul x3_s y3_s in
let y3_s = S.fadd t0_s t2_s in
let y3_s = S.fsub x3_s y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_3 x3 y3 t0 t2 p q =
let x1, z1 = getx p, getz p in
let x2, z2 = getx q, getz q in
fadd x3 x1 z1;
fadd y3 x2 z2;
fmul x3 x3 y3;
fadd y3 t0 t2;
fsub y3 x3 y3
inline_for_extraction noextract
val point_add_4 (x3 y3 z3 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t1; loc t2 ] /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\ as_nat h y3 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\ as_nat h1 z3 < S.prime /\
(let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let z3_s = S.fmul S.b_coeff t2_s in
let x3_s = S.fsub y3_s z3_s in
let z3_s = S.fadd x3_s x3_s in
let x3_s = S.fadd x3_s z3_s in
let z3_s = S.fsub t1_s x3_s in
let x3_s = S.fadd t1_s x3_s in
let y3_s = S.fmul S.b_coeff y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\ fmont_as_nat h1 z3 == z3_s))
let point_add_4 x3 y3 z3 t1 t2 =
fmul_by_b_coeff z3 t2;
fsub x3 y3 z3;
fdouble z3 x3;
fadd x3 x3 z3;
fsub z3 t1 x3;
fadd x3 t1 x3;
fmul_by_b_coeff y3 y3
inline_for_extraction noextract
val point_add_5 (x3 y3 z3 t0 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t1 < S.prime /\ as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let t1_s = S.fadd t2_s t2_s in
let t2_s = S.fadd t1_s t2_s in
let y3_s = S.fsub y3_s t2_s in
let y3_s = S.fsub y3_s t0_s in
let t1_s = S.fadd y3_s y3_s in
fmont_as_nat h1 t1 == t1_s /\ fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.PointAdd.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x3: Hacl.Impl.P256.Bignum.felem ->
y3: Hacl.Impl.P256.Bignum.felem ->
z3: Hacl.Impl.P256.Bignum.felem ->
t0: Hacl.Impl.P256.Bignum.felem ->
t1: Hacl.Impl.P256.Bignum.felem ->
t2: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Field.fdouble",
"Prims.unit",
"Hacl.Impl.P256.Field.fsub",
"Hacl.Impl.P256.Field.fadd"
] | [] | false | true | false | false | false | let point_add_5 x3 y3 z3 t0 t1 t2 =
| fdouble t1 t2;
fadd t2 t1 t2;
fsub y3 y3 t2;
fsub y3 y3 t0;
fdouble t1 y3 | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.universe_to_string | val universe_to_string (n: nat) (u: universe) : Tot string (decreases u) | val universe_to_string (n: nat) (u: universe) : Tot string (decreases u) | let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>" | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 25,
"end_line": 54,
"start_col": 0,
"start_line": 42
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | n: Prims.nat -> u12: Pulse.Syntax.Base.universe -> Prims.Tot Prims.string | Prims.Tot | [
"total",
""
] | [] | [
"Prims.nat",
"Pulse.Syntax.Base.universe",
"FStar.Stubs.Reflection.V2.Builtins.inspect_universe",
"FStar.Printf.sprintf",
"FStar.Stubs.Reflection.Types.universe",
"Pulse.Syntax.Printer.universe_to_string",
"Prims.op_Addition",
"Prims.op_Equality",
"Prims.int",
"Prims.bool",
"Prims.string",
"FStar.Stubs.Reflection.V2.Data.universes",
"FStar.Stubs.Reflection.V2.Data.universe_view"
] | [
"recursion"
] | false | false | false | true | false | let rec universe_to_string (n: nat) (u: universe) : Tot string (decreases u) =
| let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>" | false |
Lib.IntVector.Serialize.fst | Lib.IntVector.Serialize.vecs_store_le | val vecs_store_le:
#vt:v_inttype
-> #w:width
-> #len:size_t{v len * (numbytes vt * w) <= max_size_t}
-> o:lbuffer uint8 (len *! (size (numbytes vt) *! size w))
-> i:lbuffer (vec_t vt w) len ->
Stack unit
(requires fun h -> live h i /\ live h o /\ B.disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == vecs_to_bytes_le #vt #w #(v len) (as_seq h0 i)) | val vecs_store_le:
#vt:v_inttype
-> #w:width
-> #len:size_t{v len * (numbytes vt * w) <= max_size_t}
-> o:lbuffer uint8 (len *! (size (numbytes vt) *! size w))
-> i:lbuffer (vec_t vt w) len ->
Stack unit
(requires fun h -> live h i /\ live h o /\ B.disjoint i o)
(ensures fun h0 _ h1 ->
modifies1 o h0 h1 /\
as_seq h1 o == vecs_to_bytes_le #vt #w #(v len) (as_seq h0 i)) | let vecs_store_le #vt #w #len o i =
let h0 = ST.get () in
[@ inline_let]
let a_spec (i:nat{i <= v len}) = unit in
fill_blocks h0 (size (numbytes vt) *! size w) len o a_spec
(fun _ _ -> ())
(fun _ -> LowStar.Buffer.loc_none)
(fun h -> vecs_to_bytes_le_f (as_seq h i))
(fun j -> vec_store_le (sub o (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w)) i.(j));
norm_spec [delta_only [`%vecs_to_bytes_le]] (vecs_to_bytes_le (as_seq h0 i)) | {
"file_name": "lib/Lib.IntVector.Serialize.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 78,
"end_line": 128,
"start_col": 0,
"start_line": 117
} | module Lib.IntVector.Serialize
// the proofs are the same as in Lib.ByteSequence and Lib.ByteBuffer
#set-options "--z3rlimit 50 --max_fuel 0 --max_ifuel 0"
val vecs_from_bytes_le_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_le_f vt w len b i =
vec_from_bytes_le vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_le vt w len b =
LSeq.createi len (vecs_from_bytes_le_f vt w len b)
let index_vecs_from_bytes_le vt w len b i = ()
val vecs_from_bytes_be_f:
vt:v_inttype
-> w:width
-> len:nat{len * (numbytes vt * w) <= max_size_t}
-> b:lseq uint8 (len * (numbytes vt * w))
-> i:nat{i < len} ->
vec_t vt w
let vecs_from_bytes_be_f vt w len b i =
vec_from_bytes_be vt w (LSeq.sub b (i * (numbytes vt * w)) (numbytes vt * w))
let vecs_from_bytes_be vt w len b =
LSeq.createi len (vecs_from_bytes_be_f vt w len b)
let index_vecs_from_bytes_be vt w len b i = ()
val vecs_to_bytes_le_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_le_f #vt #w #len vl i () =
(), vec_to_bytes_le vl.[i]
let vecs_to_bytes_le #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_le_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_le #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_le_f #vt #w #len vl) i
val vecs_to_bytes_be_f:
#vt:v_inttype
-> #w:width
-> #len:nat{len * (numbytes vt * w) <= max_size_t}
-> vl:lseq (vec_t vt w) len
-> i:nat{i < len}
-> unit ->
unit & lseq uint8 (numbytes vt * w)
let vecs_to_bytes_be_f #vt #w #len vl i () =
(), vec_to_bytes_be vl.[i]
let vecs_to_bytes_be #vt #w #len vl =
let a_spec (i:nat{i <= len}) = unit in
let _, o = generate_blocks (numbytes vt * w) len len a_spec
(vecs_to_bytes_be_f #vt #w #len vl) () in
o
let index_vecs_to_bytes_be #vt #w #len vl i =
index_generate_blocks (numbytes vt * w) len len
(vecs_to_bytes_be_f #vt #w #len vl) i
let vecs_load_le #vt #w #len o i =
let h0 = ST.get () in
fill h0 len o
(fun h -> vecs_from_bytes_le_f vt w (v len) (as_seq h i))
(fun j ->
let h = ST.get () in
let bj = sub i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w) in
let r = vec_load_le vt w bj in
as_seq_gsub h i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w);
r);
let h1 = ST.get () in
eq_intro (as_seq h1 o) (vecs_from_bytes_le vt w (v len) (as_seq h0 i))
let vecs_load_be #vt #w #len o i =
let h0 = ST.get () in
fill h0 len o
(fun h -> vecs_from_bytes_be_f vt w (v len) (as_seq h i))
(fun j ->
let h = ST.get () in
let bj = sub i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w) in
let r = vec_load_be vt w bj in
as_seq_gsub h i (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w);
r);
let h1 = ST.get () in
eq_intro (as_seq h1 o) (vecs_from_bytes_be vt w (v len) (as_seq h0 i))
#set-options "--z3rlimit 100" | {
"checked_file": "/",
"dependencies": [
"prims.fst.checked",
"LowStar.Buffer.fst.checked",
"FStar.ST.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked"
],
"interface_file": true,
"source_file": "Lib.IntVector.Serialize.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": true,
"full_module": "Lib.Buffer",
"short_module": "B"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "Lib.ByteSequence",
"short_module": "BSeq"
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Sequence",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntVector",
"short_module": null
},
{
"abbrev": 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": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 100,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
o:
Lib.Buffer.lbuffer Lib.IntTypes.uint8
(len *! (Lib.IntTypes.size (Lib.IntTypes.numbytes vt) *! Lib.IntTypes.size w)) ->
i: Lib.Buffer.lbuffer (Lib.IntVector.vec_t vt w) len
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Lib.IntVector.v_inttype",
"Lib.IntVector.width",
"Lib.IntTypes.size_t",
"Prims.b2t",
"Prims.op_LessThanOrEqual",
"FStar.Mul.op_Star",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Lib.IntTypes.numbytes",
"Lib.IntTypes.max_size_t",
"Lib.Buffer.lbuffer",
"Lib.IntTypes.uint8",
"Lib.IntTypes.op_Star_Bang",
"Lib.IntTypes.size",
"Lib.IntVector.vec_t",
"FStar.Pervasives.norm_spec",
"Prims.Cons",
"FStar.Pervasives.norm_step",
"FStar.Pervasives.delta_only",
"Prims.string",
"Prims.Nil",
"Lib.Sequence.lseq",
"Lib.IntVector.Serialize.vecs_to_bytes_le",
"Lib.Buffer.as_seq",
"Lib.Buffer.MUT",
"Prims.unit",
"Lib.Buffer.fill_blocks",
"FStar.Monotonic.HyperStack.mem",
"Lib.IntTypes.size_nat",
"LowStar.Monotonic.Buffer.loc_none",
"LowStar.Monotonic.Buffer.loc",
"Prims.l_and",
"LowStar.Monotonic.Buffer.loc_disjoint",
"Lib.Buffer.loc",
"LowStar.Monotonic.Buffer.loc_includes",
"LowStar.Monotonic.Buffer.address_liveness_insensitive_locs",
"Lib.IntVector.Serialize.vecs_to_bytes_le_f",
"Prims.op_LessThan",
"FStar.Pervasives.Native.tuple2",
"Prims.op_Addition",
"Lib.IntVector.vec_store_le",
"Lib.Buffer.op_Array_Access",
"Lib.Buffer.lbuffer_t",
"Lib.IntTypes.int_t",
"Lib.IntTypes.U8",
"Lib.IntTypes.SEC",
"Lib.IntTypes.mul",
"Lib.IntTypes.mk_int",
"Lib.Buffer.sub",
"Prims.nat",
"Prims.eqtype",
"FStar.HyperStack.ST.get"
] | [] | false | true | false | false | false | let vecs_store_le #vt #w #len o i =
| let h0 = ST.get () in
[@@ inline_let ]let a_spec (i: nat{i <= v len}) = unit in
fill_blocks h0
(size (numbytes vt) *! size w)
len
o
a_spec
(fun _ _ -> ())
(fun _ -> LowStar.Buffer.loc_none)
(fun h -> vecs_to_bytes_le_f (as_seq h i))
(fun j ->
vec_store_le (sub o (j *! (size (numbytes vt) *! size w)) (size (numbytes vt) *! size w))
i.(j));
norm_spec [delta_only [`%vecs_to_bytes_le]] (vecs_to_bytes_le (as_seq h0 i)) | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.collect_binders | val collect_binders (until: (term' -> bool)) (t: term) : list binder & term | val collect_binders (until: (term' -> bool)) (t: term) : list binder & term | let rec collect_binders (until: term' -> bool) (t:term) : list binder & term =
if not (until t.t) then [], t
else (
match t.t with
| Tm_ExistsSL _ b body
| Tm_ForallSL _ b body ->
let bs, t = collect_binders until body in
b::bs, t
| _ -> [], t
) | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 3,
"end_line": 73,
"start_col": 0,
"start_line": 64
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>"
let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u)
let qual_to_string = function
| None -> ""
| Some Implicit -> "#"
let indent (level:string) = level ^ "\t" | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | until: (_: Pulse.Syntax.Base.term' -> Prims.bool) -> t: Pulse.Syntax.Base.term
-> Prims.list Pulse.Syntax.Base.binder * Pulse.Syntax.Base.term | Prims.Tot | [
"total"
] | [] | [
"Pulse.Syntax.Base.term'",
"Prims.bool",
"Pulse.Syntax.Base.term",
"Prims.op_Negation",
"Pulse.Syntax.Base.__proj__Mkterm__item__t",
"FStar.Pervasives.Native.Mktuple2",
"Prims.list",
"Pulse.Syntax.Base.binder",
"Prims.Nil",
"Pulse.Syntax.Base.universe",
"Prims.Cons",
"FStar.Pervasives.Native.tuple2",
"Pulse.Syntax.Printer.collect_binders"
] | [
"recursion"
] | false | false | false | true | false | let rec collect_binders (until: (term' -> bool)) (t: term) : list binder & term =
| if not (until t.t)
then [], t
else
(match t.t with
| Tm_ExistsSL _ b body
| Tm_ForallSL _ b body ->
let bs, t = collect_binders until body in
b :: bs, t
| _ -> [], t) | false |
Hacl.Impl.P256.PointAdd.fst | Hacl.Impl.P256.PointAdd.point_add_7 | val point_add_7 (x3 y3 z3 t0 t1 t2 t3 t4:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\
LowStar.Monotonic.Buffer.all_disjoint
[ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
as_nat h x3 < S.prime /\ as_nat h z3 < S.prime /\
as_nat h t0 < S.prime /\ as_nat h t1 < S.prime /\
as_nat h t2 < S.prime /\ as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3 |+| loc t1) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
as_nat h1 z3 < S.prime /\ as_nat h1 t1 < S.prime /\
(let x3_s = fmont_as_nat h0 x3 in
let z3_s = fmont_as_nat h0 z3 in
let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let y3_s = S.fmul x3_s z3_s in
let y3_s = S.fadd y3_s t2_s in
let x3_s = S.fmul t3_s x3_s in
let x3_s = S.fsub x3_s t1_s in
let z3_s = S.fmul t4_s z3_s in
let t1_s = S.fmul t3_s t0_s in
let z3_s = S.fadd z3_s t1_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\
fmont_as_nat h1 z3 == z3_s /\ fmont_as_nat h1 t1 == t1_s)) | val point_add_7 (x3 y3 z3 t0 t1 t2 t3 t4:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\
LowStar.Monotonic.Buffer.all_disjoint
[ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
as_nat h x3 < S.prime /\ as_nat h z3 < S.prime /\
as_nat h t0 < S.prime /\ as_nat h t1 < S.prime /\
as_nat h t2 < S.prime /\ as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3 |+| loc t1) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
as_nat h1 z3 < S.prime /\ as_nat h1 t1 < S.prime /\
(let x3_s = fmont_as_nat h0 x3 in
let z3_s = fmont_as_nat h0 z3 in
let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let y3_s = S.fmul x3_s z3_s in
let y3_s = S.fadd y3_s t2_s in
let x3_s = S.fmul t3_s x3_s in
let x3_s = S.fsub x3_s t1_s in
let z3_s = S.fmul t4_s z3_s in
let t1_s = S.fmul t3_s t0_s in
let z3_s = S.fadd z3_s t1_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\
fmont_as_nat h1 z3 == z3_s /\ fmont_as_nat h1 t1 == t1_s)) | let point_add_7 x3 y3 z3 t0 t1 t2 t3 t4 =
fmul y3 x3 z3;
fadd y3 y3 t2;
fmul x3 t3 x3;
fsub x3 x3 t1;
fmul z3 t4 z3;
fmul t1 t3 t0;
fadd z3 z3 t1 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 268,
"start_col": 0,
"start_line": 261
} | module Hacl.Impl.P256.PointAdd
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
module S = Spec.P256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s))
let point_add_1 t0 t1 t2 t3 t4 p q =
let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
fmul t0 x1 x2;
fmul t1 y1 y2;
fmul t2 z1 z2;
fadd t3 x1 y1;
fadd t4 x2 y2;
fmul t3 t3 t4;
fadd t4 t0 t1
inline_for_extraction noextract
val point_add_2 (t1 t2 t3 t4 t5:felem) (p q:point) : Stack unit
(requires fun h ->
live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\ live h t5 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc t1; loc t2; loc t3; loc t4; loc t5 ] /\
eq_or_disjoint p q /\ disjoint p t1 /\ disjoint p t2 /\
disjoint p t3 /\ disjoint p t4 /\ disjoint p t5 /\
disjoint q t1 /\ disjoint q t2 /\ disjoint q t3 /\
disjoint q t4 /\ disjoint q t5 /\
point_inv h p /\ point_inv h q /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc t3 |+| loc t4 |+| loc t5) h0 h1 /\
as_nat h1 t3 < S.prime /\ as_nat h1 t4 < S.prime /\ as_nat h1 t5 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let t3_s = S.fsub t3_s t4_s in
let t4_s = S.fadd y1 z1 in
let t5_s = S.fadd y2 z2 in
let t4_s = S.fmul t4_s t5_s in
let t5_s = S.fadd t1_s t2_s in
let t4_s = S.fsub t4_s t5_s in
fmont_as_nat h1 t3 == t3_s /\ fmont_as_nat h1 t4 == t4_s /\
fmont_as_nat h1 t5 == t5_s))
let point_add_2 t1 t2 t3 t4 t5 p q =
let y1, z1 = gety p, getz p in
let y2, z2 = gety q, getz q in
fsub t3 t3 t4;
fadd t4 y1 z1;
fadd t5 y2 z2;
fmul t4 t4 t5;
fadd t5 t1 t2;
fsub t4 t4 t5
inline_for_extraction noextract
val point_add_3 (x3 y3 t0 t2:felem) (p q:point) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h t0 /\ live h t2 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc t0; loc t2 ] /\
eq_or_disjoint p q /\ disjoint p x3 /\ disjoint p y3 /\
disjoint p t0 /\ disjoint p t2 /\ disjoint q x3 /\
disjoint q y3 /\ disjoint q t0 /\ disjoint q t2 /\
point_inv h p /\ point_inv h q /\
as_nat h t0 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = fmont_as_nat h0 t0 in
let t2_s = fmont_as_nat h0 t2 in
let x3_s = S.fadd x1 z1 in
let y3_s = S.fadd x2 z2 in
let x3_s = S.fmul x3_s y3_s in
let y3_s = S.fadd t0_s t2_s in
let y3_s = S.fsub x3_s y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_3 x3 y3 t0 t2 p q =
let x1, z1 = getx p, getz p in
let x2, z2 = getx q, getz q in
fadd x3 x1 z1;
fadd y3 x2 z2;
fmul x3 x3 y3;
fadd y3 t0 t2;
fsub y3 x3 y3
inline_for_extraction noextract
val point_add_4 (x3 y3 z3 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t1; loc t2 ] /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\ as_nat h y3 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\ as_nat h1 z3 < S.prime /\
(let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let z3_s = S.fmul S.b_coeff t2_s in
let x3_s = S.fsub y3_s z3_s in
let z3_s = S.fadd x3_s x3_s in
let x3_s = S.fadd x3_s z3_s in
let z3_s = S.fsub t1_s x3_s in
let x3_s = S.fadd t1_s x3_s in
let y3_s = S.fmul S.b_coeff y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\ fmont_as_nat h1 z3 == z3_s))
let point_add_4 x3 y3 z3 t1 t2 =
fmul_by_b_coeff z3 t2;
fsub x3 y3 z3;
fdouble z3 x3;
fadd x3 x3 z3;
fsub z3 t1 x3;
fadd x3 t1 x3;
fmul_by_b_coeff y3 y3
inline_for_extraction noextract
val point_add_5 (x3 y3 z3 t0 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t1 < S.prime /\ as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let t1_s = S.fadd t2_s t2_s in
let t2_s = S.fadd t1_s t2_s in
let y3_s = S.fsub y3_s t2_s in
let y3_s = S.fsub y3_s t0_s in
let t1_s = S.fadd y3_s y3_s in
fmont_as_nat h1 t1 == t1_s /\ fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_5 x3 y3 z3 t0 t1 t2 =
fdouble t1 t2;
fadd t2 t1 t2;
fsub y3 y3 t2;
fsub y3 y3 t0;
fdouble t1 y3
inline_for_extraction noextract
val point_add_6 (x3 y3 z3 t0 t1 t2 t4:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\ live h t4 /\
LowStar.Monotonic.Buffer.all_disjoint
[ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2; loc t4 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t0 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t4_s = fmont_as_nat h0 t4 in
let y3_s = fmont_as_nat h0 y3 in
let y3_s = S.fadd t1_s y3_s in
let t1_s = S.fadd t0_s t0_s in
let t0_s = S.fadd t1_s t0_s in
let t0_s = S.fsub t0_s t2_s in
let t1_s = S.fmul t4_s y3_s in
let t2_s = S.fmul t0_s y3_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_6 x3 y3 z3 t0 t1 t2 t4 =
fadd y3 t1 y3;
fdouble t1 t0;
fadd t0 t1 t0;
fsub t0 t0 t2;
fmul t1 t4 y3;
fmul t2 t0 y3
inline_for_extraction noextract
val point_add_7 (x3 y3 z3 t0 t1 t2 t3 t4:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\
LowStar.Monotonic.Buffer.all_disjoint
[ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
as_nat h x3 < S.prime /\ as_nat h z3 < S.prime /\
as_nat h t0 < S.prime /\ as_nat h t1 < S.prime /\
as_nat h t2 < S.prime /\ as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3 |+| loc t1) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
as_nat h1 z3 < S.prime /\ as_nat h1 t1 < S.prime /\
(let x3_s = fmont_as_nat h0 x3 in
let z3_s = fmont_as_nat h0 z3 in
let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let y3_s = S.fmul x3_s z3_s in
let y3_s = S.fadd y3_s t2_s in
let x3_s = S.fmul t3_s x3_s in
let x3_s = S.fsub x3_s t1_s in
let z3_s = S.fmul t4_s z3_s in
let t1_s = S.fmul t3_s t0_s in
let z3_s = S.fadd z3_s t1_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\
fmont_as_nat h1 z3 == z3_s /\ fmont_as_nat h1 t1 == t1_s)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.PointAdd.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x3: Hacl.Impl.P256.Bignum.felem ->
y3: Hacl.Impl.P256.Bignum.felem ->
z3: Hacl.Impl.P256.Bignum.felem ->
t0: Hacl.Impl.P256.Bignum.felem ->
t1: Hacl.Impl.P256.Bignum.felem ->
t2: Hacl.Impl.P256.Bignum.felem ->
t3: Hacl.Impl.P256.Bignum.felem ->
t4: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Field.fadd",
"Prims.unit",
"Hacl.Impl.P256.Field.fmul",
"Hacl.Impl.P256.Field.fsub"
] | [] | false | true | false | false | false | let point_add_7 x3 y3 z3 t0 t1 t2 t3 t4 =
| fmul y3 x3 z3;
fadd y3 y3 t2;
fmul x3 t3 x3;
fsub x3 x3 t1;
fmul z3 t4 z3;
fmul t1 t3 t0;
fadd z3 z3 t1 | false |
Hacl.Impl.P256.PointAdd.fst | Hacl.Impl.P256.PointAdd.point_add_2 | val point_add_2 (t1 t2 t3 t4 t5:felem) (p q:point) : Stack unit
(requires fun h ->
live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\ live h t5 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc t1; loc t2; loc t3; loc t4; loc t5 ] /\
eq_or_disjoint p q /\ disjoint p t1 /\ disjoint p t2 /\
disjoint p t3 /\ disjoint p t4 /\ disjoint p t5 /\
disjoint q t1 /\ disjoint q t2 /\ disjoint q t3 /\
disjoint q t4 /\ disjoint q t5 /\
point_inv h p /\ point_inv h q /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc t3 |+| loc t4 |+| loc t5) h0 h1 /\
as_nat h1 t3 < S.prime /\ as_nat h1 t4 < S.prime /\ as_nat h1 t5 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let t3_s = S.fsub t3_s t4_s in
let t4_s = S.fadd y1 z1 in
let t5_s = S.fadd y2 z2 in
let t4_s = S.fmul t4_s t5_s in
let t5_s = S.fadd t1_s t2_s in
let t4_s = S.fsub t4_s t5_s in
fmont_as_nat h1 t3 == t3_s /\ fmont_as_nat h1 t4 == t4_s /\
fmont_as_nat h1 t5 == t5_s)) | val point_add_2 (t1 t2 t3 t4 t5:felem) (p q:point) : Stack unit
(requires fun h ->
live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\ live h t5 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc t1; loc t2; loc t3; loc t4; loc t5 ] /\
eq_or_disjoint p q /\ disjoint p t1 /\ disjoint p t2 /\
disjoint p t3 /\ disjoint p t4 /\ disjoint p t5 /\
disjoint q t1 /\ disjoint q t2 /\ disjoint q t3 /\
disjoint q t4 /\ disjoint q t5 /\
point_inv h p /\ point_inv h q /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc t3 |+| loc t4 |+| loc t5) h0 h1 /\
as_nat h1 t3 < S.prime /\ as_nat h1 t4 < S.prime /\ as_nat h1 t5 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let t3_s = S.fsub t3_s t4_s in
let t4_s = S.fadd y1 z1 in
let t5_s = S.fadd y2 z2 in
let t4_s = S.fmul t4_s t5_s in
let t5_s = S.fadd t1_s t2_s in
let t4_s = S.fsub t4_s t5_s in
fmont_as_nat h1 t3 == t3_s /\ fmont_as_nat h1 t4 == t4_s /\
fmont_as_nat h1 t5 == t5_s)) | let point_add_2 t1 t2 t3 t4 t5 p q =
let y1, z1 = gety p, getz p in
let y2, z2 = gety q, getz q in
fsub t3 t3 t4;
fadd t4 y1 z1;
fadd t5 y2 z2;
fmul t4 t4 t5;
fadd t5 t1 t2;
fsub t4 t4 t5 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 99,
"start_col": 0,
"start_line": 91
} | module Hacl.Impl.P256.PointAdd
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
module S = Spec.P256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s))
let point_add_1 t0 t1 t2 t3 t4 p q =
let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
fmul t0 x1 x2;
fmul t1 y1 y2;
fmul t2 z1 z2;
fadd t3 x1 y1;
fadd t4 x2 y2;
fmul t3 t3 t4;
fadd t4 t0 t1
inline_for_extraction noextract
val point_add_2 (t1 t2 t3 t4 t5:felem) (p q:point) : Stack unit
(requires fun h ->
live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\ live h t5 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc t1; loc t2; loc t3; loc t4; loc t5 ] /\
eq_or_disjoint p q /\ disjoint p t1 /\ disjoint p t2 /\
disjoint p t3 /\ disjoint p t4 /\ disjoint p t5 /\
disjoint q t1 /\ disjoint q t2 /\ disjoint q t3 /\
disjoint q t4 /\ disjoint q t5 /\
point_inv h p /\ point_inv h q /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc t3 |+| loc t4 |+| loc t5) h0 h1 /\
as_nat h1 t3 < S.prime /\ as_nat h1 t4 < S.prime /\ as_nat h1 t5 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let t3_s = S.fsub t3_s t4_s in
let t4_s = S.fadd y1 z1 in
let t5_s = S.fadd y2 z2 in
let t4_s = S.fmul t4_s t5_s in
let t5_s = S.fadd t1_s t2_s in
let t4_s = S.fsub t4_s t5_s in
fmont_as_nat h1 t3 == t3_s /\ fmont_as_nat h1 t4 == t4_s /\
fmont_as_nat h1 t5 == t5_s)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.PointAdd.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t1: Hacl.Impl.P256.Bignum.felem ->
t2: Hacl.Impl.P256.Bignum.felem ->
t3: Hacl.Impl.P256.Bignum.felem ->
t4: Hacl.Impl.P256.Bignum.felem ->
t5: Hacl.Impl.P256.Bignum.felem ->
p: Hacl.Impl.P256.Point.point ->
q: Hacl.Impl.P256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Field.fsub",
"Prims.unit",
"Hacl.Impl.P256.Field.fadd",
"Hacl.Impl.P256.Field.fmul",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Hacl.Impl.P256.Point.getz",
"Hacl.Impl.P256.Point.gety"
] | [] | false | true | false | false | false | let point_add_2 t1 t2 t3 t4 t5 p q =
| let y1, z1 = gety p, getz p in
let y2, z2 = gety q, getz q in
fsub t3 t3 t4;
fadd t4 y1 z1;
fadd t5 y2 z2;
fmul t4 t4 t5;
fadd t5 t1 t2;
fsub t4 t4 t5 | false |
Hacl.Impl.P256.PointAdd.fst | Hacl.Impl.P256.PointAdd.point_add_3 | val point_add_3 (x3 y3 t0 t2:felem) (p q:point) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h t0 /\ live h t2 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc t0; loc t2 ] /\
eq_or_disjoint p q /\ disjoint p x3 /\ disjoint p y3 /\
disjoint p t0 /\ disjoint p t2 /\ disjoint q x3 /\
disjoint q y3 /\ disjoint q t0 /\ disjoint q t2 /\
point_inv h p /\ point_inv h q /\
as_nat h t0 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = fmont_as_nat h0 t0 in
let t2_s = fmont_as_nat h0 t2 in
let x3_s = S.fadd x1 z1 in
let y3_s = S.fadd x2 z2 in
let x3_s = S.fmul x3_s y3_s in
let y3_s = S.fadd t0_s t2_s in
let y3_s = S.fsub x3_s y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s)) | val point_add_3 (x3 y3 t0 t2:felem) (p q:point) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h t0 /\ live h t2 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc t0; loc t2 ] /\
eq_or_disjoint p q /\ disjoint p x3 /\ disjoint p y3 /\
disjoint p t0 /\ disjoint p t2 /\ disjoint q x3 /\
disjoint q y3 /\ disjoint q t0 /\ disjoint q t2 /\
point_inv h p /\ point_inv h q /\
as_nat h t0 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = fmont_as_nat h0 t0 in
let t2_s = fmont_as_nat h0 t2 in
let x3_s = S.fadd x1 z1 in
let y3_s = S.fadd x2 z2 in
let x3_s = S.fmul x3_s y3_s in
let y3_s = S.fadd t0_s t2_s in
let y3_s = S.fsub x3_s y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s)) | let point_add_3 x3 y3 t0 t2 p q =
let x1, z1 = getx p, getz p in
let x2, z2 = getx q, getz q in
fadd x3 x1 z1;
fadd y3 x2 z2;
fmul x3 x3 y3;
fadd y3 t0 t2;
fsub y3 x3 y3 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 133,
"start_col": 0,
"start_line": 126
} | module Hacl.Impl.P256.PointAdd
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
module S = Spec.P256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s))
let point_add_1 t0 t1 t2 t3 t4 p q =
let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
fmul t0 x1 x2;
fmul t1 y1 y2;
fmul t2 z1 z2;
fadd t3 x1 y1;
fadd t4 x2 y2;
fmul t3 t3 t4;
fadd t4 t0 t1
inline_for_extraction noextract
val point_add_2 (t1 t2 t3 t4 t5:felem) (p q:point) : Stack unit
(requires fun h ->
live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\ live h t5 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc t1; loc t2; loc t3; loc t4; loc t5 ] /\
eq_or_disjoint p q /\ disjoint p t1 /\ disjoint p t2 /\
disjoint p t3 /\ disjoint p t4 /\ disjoint p t5 /\
disjoint q t1 /\ disjoint q t2 /\ disjoint q t3 /\
disjoint q t4 /\ disjoint q t5 /\
point_inv h p /\ point_inv h q /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc t3 |+| loc t4 |+| loc t5) h0 h1 /\
as_nat h1 t3 < S.prime /\ as_nat h1 t4 < S.prime /\ as_nat h1 t5 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let t3_s = S.fsub t3_s t4_s in
let t4_s = S.fadd y1 z1 in
let t5_s = S.fadd y2 z2 in
let t4_s = S.fmul t4_s t5_s in
let t5_s = S.fadd t1_s t2_s in
let t4_s = S.fsub t4_s t5_s in
fmont_as_nat h1 t3 == t3_s /\ fmont_as_nat h1 t4 == t4_s /\
fmont_as_nat h1 t5 == t5_s))
let point_add_2 t1 t2 t3 t4 t5 p q =
let y1, z1 = gety p, getz p in
let y2, z2 = gety q, getz q in
fsub t3 t3 t4;
fadd t4 y1 z1;
fadd t5 y2 z2;
fmul t4 t4 t5;
fadd t5 t1 t2;
fsub t4 t4 t5
inline_for_extraction noextract
val point_add_3 (x3 y3 t0 t2:felem) (p q:point) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h t0 /\ live h t2 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc t0; loc t2 ] /\
eq_or_disjoint p q /\ disjoint p x3 /\ disjoint p y3 /\
disjoint p t0 /\ disjoint p t2 /\ disjoint q x3 /\
disjoint q y3 /\ disjoint q t0 /\ disjoint q t2 /\
point_inv h p /\ point_inv h q /\
as_nat h t0 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = fmont_as_nat h0 t0 in
let t2_s = fmont_as_nat h0 t2 in
let x3_s = S.fadd x1 z1 in
let y3_s = S.fadd x2 z2 in
let x3_s = S.fmul x3_s y3_s in
let y3_s = S.fadd t0_s t2_s in
let y3_s = S.fsub x3_s y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.PointAdd.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x3: Hacl.Impl.P256.Bignum.felem ->
y3: Hacl.Impl.P256.Bignum.felem ->
t0: Hacl.Impl.P256.Bignum.felem ->
t2: Hacl.Impl.P256.Bignum.felem ->
p: Hacl.Impl.P256.Point.point ->
q: Hacl.Impl.P256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Field.fsub",
"Prims.unit",
"Hacl.Impl.P256.Field.fadd",
"Hacl.Impl.P256.Field.fmul",
"FStar.Pervasives.Native.tuple2",
"FStar.Pervasives.Native.Mktuple2",
"Hacl.Impl.P256.Point.getz",
"Hacl.Impl.P256.Point.getx"
] | [] | false | true | false | false | false | let point_add_3 x3 y3 t0 t2 p q =
| let x1, z1 = getx p, getz p in
let x2, z2 = getx q, getz q in
fadd x3 x1 z1;
fadd y3 x2 z2;
fmul x3 x3 y3;
fadd y3 t0 t2;
fsub y3 x3 y3 | false |
Hacl.Impl.P256.PointAdd.fst | Hacl.Impl.P256.PointAdd.point_add_1 | val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s)) | val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s)) | let point_add_1 t0 t1 t2 t3 t4 p q =
let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
fmul t0 x1 x2;
fmul t1 y1 y2;
fmul t2 z1 z2;
fadd t3 x1 y1;
fadd t4 x2 y2;
fmul t3 t3 t4;
fadd t4 t0 t1 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 57,
"start_col": 0,
"start_line": 48
} | module Hacl.Impl.P256.PointAdd
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
module S = Spec.P256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.PointAdd.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
t0: Hacl.Impl.P256.Bignum.felem ->
t1: Hacl.Impl.P256.Bignum.felem ->
t2: Hacl.Impl.P256.Bignum.felem ->
t3: Hacl.Impl.P256.Bignum.felem ->
t4: Hacl.Impl.P256.Bignum.felem ->
p: Hacl.Impl.P256.Point.point ->
q: Hacl.Impl.P256.Point.point
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Point.point",
"Hacl.Impl.P256.Field.fadd",
"Prims.unit",
"Hacl.Impl.P256.Field.fmul",
"FStar.Pervasives.Native.tuple3",
"FStar.Pervasives.Native.Mktuple3",
"Hacl.Impl.P256.Point.getz",
"Hacl.Impl.P256.Point.gety",
"Hacl.Impl.P256.Point.getx"
] | [] | false | true | false | false | false | let point_add_1 t0 t1 t2 t3 t4 p q =
| let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
fmul t0 x1 x2;
fmul t1 y1 y2;
fmul t2 z1 z2;
fadd t3 x1 y1;
fadd t4 x2 y2;
fmul t3 t3 t4;
fadd t4 t0 t1 | false |
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.term_to_doc | val term_to_doc (t:term) : T.Tac document | val term_to_doc (t:term) : T.Tac document | let rec binder_to_doc b : T.Tac document =
parens (doc_of_string (T.unseal b.binder_ppname.name)
^^ doc_of_string ":"
^^ term_to_doc b.binder_ty)
and term_to_doc t
: T.Tac document
= match t.t with
| Tm_Emp -> doc_of_string "emp"
| Tm_Pure p -> doc_of_string "pure" ^^ parens (term_to_doc p)
| Tm_Star p1 p2 ->
infix 2 1 (doc_of_string "**")
(term_to_doc p1)
(term_to_doc p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
parens (doc_of_string "exists*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_ForallSL _ _ _ ->
let bs, body = collect_binders Tm_ForallSL? t in
parens (doc_of_string "forall*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_VProp -> doc_of_string "vprop"
| Tm_Inames -> doc_of_string "inames"
| Tm_EmpInames -> doc_of_string "emp_inames"
| Tm_AddInv i is ->
doc_of_string "add_inv" ^/^ parens (term_to_doc i ^^ doc_of_string "," ^^ term_to_doc is)
| Tm_Inv i ->
doc_of_string "inv" ^/^ parens (term_to_doc i)
| Tm_Unknown -> doc_of_string "_"
| Tm_FStar t ->
// Should call term_to_doc when available
doc_of_string (T.term_to_string t) | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 40,
"end_line": 166,
"start_col": 0,
"start_line": 128
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>"
let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u)
let qual_to_string = function
| None -> ""
| Some Implicit -> "#"
let indent (level:string) = level ^ "\t"
let rec collect_binders (until: term' -> bool) (t:term) : list binder & term =
if not (until t.t) then [], t
else (
match t.t with
| Tm_ExistsSL _ b body
| Tm_ForallSL _ b body ->
let bs, t = collect_binders until body in
b::bs, t
| _ -> [], t
)
let rec binder_to_string_paren (b:binder)
: T.Tac string
= sprintf "(%s%s:%s)"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string' "" b.binder_ty)
and term_to_string' (level:string) (t:term)
: T.Tac string
= match t.t with
| Tm_Emp -> "emp"
| Tm_Pure p ->
sprintf "pure (%s)"
(term_to_string' (indent level) p)
| Tm_Star p1 p2 ->
sprintf "%s ** \n%s%s"
(term_to_string' level p1)
level
(term_to_string' level p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
sprintf "(exists* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_ForallSL u b body ->
let bs, body = collect_binders Tm_ForallSL? t in
sprintf "(forall* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_VProp -> "vprop"
| Tm_Inames -> "inames"
| Tm_EmpInames -> "emp_inames"
| Tm_Unknown -> "_"
| Tm_AddInv i is ->
sprintf "add_inv %s %s"
(term_to_string' level i)
(term_to_string' level is)
| Tm_Inv i ->
sprintf "inv %s"
(term_to_string' level i)
| Tm_FStar t ->
T.term_to_string t
let term_to_string t = term_to_string' "" t | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | t: Pulse.Syntax.Base.term -> FStar.Tactics.Effect.Tac FStar.Stubs.Pprint.document | FStar.Tactics.Effect.Tac | [] | [
"binder_to_doc",
"term_to_doc"
] | [
"Pulse.Syntax.Base.term",
"Pulse.Syntax.Base.__proj__Mkterm__item__t",
"FStar.Stubs.Pprint.doc_of_string",
"FStar.Stubs.Pprint.document",
"FStar.Stubs.Pprint.op_Hat_Hat",
"FStar.Stubs.Pprint.parens",
"Pulse.Syntax.Printer.term_to_doc",
"FStar.Stubs.Pprint.infix",
"Pulse.Syntax.Base.universe",
"Pulse.Syntax.Base.binder",
"Prims.list",
"FStar.Stubs.Pprint.op_Hat_Slash_Hat",
"FStar.Stubs.Pprint.separate",
"FStar.Tactics.Util.map",
"Pulse.Syntax.Printer.binder_to_doc",
"FStar.Pervasives.Native.tuple2",
"Pulse.Syntax.Printer.collect_binders",
"Pulse.Syntax.Base.uu___is_Tm_ExistsSL",
"Pulse.Syntax.Base.uu___is_Tm_ForallSL",
"Pulse.Syntax.Base.host_term",
"Prims.string",
"FStar.Stubs.Tactics.V2.Builtins.term_to_string"
] | [
"mutual recursion"
] | false | true | false | false | false | let rec term_to_doc t : T.Tac document =
| match t.t with
| Tm_Emp -> doc_of_string "emp"
| Tm_Pure p -> doc_of_string "pure" ^^ parens (term_to_doc p)
| Tm_Star p1 p2 -> infix 2 1 (doc_of_string "**") (term_to_doc p1) (term_to_doc p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
parens (doc_of_string "exists*" ^/^
(separate (doc_of_string " ") (T.map binder_to_doc bs)) ^^
doc_of_string "." ^/^ term_to_doc body)
| Tm_ForallSL _ _ _ ->
let bs, body = collect_binders Tm_ForallSL? t in
parens (doc_of_string "forall*" ^/^
(separate (doc_of_string " ") (T.map binder_to_doc bs)) ^^
doc_of_string "." ^/^ term_to_doc body)
| Tm_VProp -> doc_of_string "vprop"
| Tm_Inames -> doc_of_string "inames"
| Tm_EmpInames -> doc_of_string "emp_inames"
| Tm_AddInv i is ->
doc_of_string "add_inv" ^/^ parens (term_to_doc i ^^ doc_of_string "," ^^ term_to_doc is)
| Tm_Inv i -> doc_of_string "inv" ^/^ parens (term_to_doc i)
| Tm_Unknown -> doc_of_string "_"
| Tm_FStar t -> doc_of_string (T.term_to_string t) | false |
Hacl.Impl.P256.PointAdd.fst | Hacl.Impl.P256.PointAdd.point_add_6 | val point_add_6 (x3 y3 z3 t0 t1 t2 t4:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\ live h t4 /\
LowStar.Monotonic.Buffer.all_disjoint
[ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2; loc t4 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t0 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t4_s = fmont_as_nat h0 t4 in
let y3_s = fmont_as_nat h0 y3 in
let y3_s = S.fadd t1_s y3_s in
let t1_s = S.fadd t0_s t0_s in
let t0_s = S.fadd t1_s t0_s in
let t0_s = S.fsub t0_s t2_s in
let t1_s = S.fmul t4_s y3_s in
let t2_s = S.fmul t0_s y3_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s)) | val point_add_6 (x3 y3 z3 t0 t1 t2 t4:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\ live h t4 /\
LowStar.Monotonic.Buffer.all_disjoint
[ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2; loc t4 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t0 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t4_s = fmont_as_nat h0 t4 in
let y3_s = fmont_as_nat h0 y3 in
let y3_s = S.fadd t1_s y3_s in
let t1_s = S.fadd t0_s t0_s in
let t0_s = S.fadd t1_s t0_s in
let t0_s = S.fsub t0_s t2_s in
let t1_s = S.fmul t4_s y3_s in
let t2_s = S.fmul t0_s y3_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s)) | let point_add_6 x3 y3 z3 t0 t1 t2 t4 =
fadd y3 t1 y3;
fdouble t1 t0;
fadd t0 t1 t0;
fsub t0 t0 t2;
fmul t1 t4 y3;
fmul t2 t0 y3 | {
"file_name": "code/ecdsap256/Hacl.Impl.P256.PointAdd.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 15,
"end_line": 228,
"start_col": 0,
"start_line": 222
} | module Hacl.Impl.P256.PointAdd
open FStar.Mul
open FStar.HyperStack.All
open FStar.HyperStack
module ST = FStar.HyperStack.ST
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.P256.Bignum
open Hacl.Impl.P256.Field
module S = Spec.P256
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
val point_add_1 (t0 t1 t2 t3 t4:felem) (p q:point) : Stack unit
(requires fun h ->
live h t0 /\ live h t1 /\ live h t2 /\
live h t3 /\ live h t4 /\ live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint
[loc t0; loc t1; loc t2; loc t3; loc t4 ] /\
eq_or_disjoint p q /\ disjoint p t0 /\ disjoint p t1 /\
disjoint p t2 /\ disjoint p t3 /\ disjoint p t4 /\
disjoint q t0 /\ disjoint q t1 /\ disjoint q t2 /\
disjoint q t3 /\ disjoint q t4 /\
point_inv h p /\ point_inv h q)
(ensures fun h0 _ h1 -> modifies (loc t0 |+| loc t1 |+| loc t2 |+| loc t3 |+| loc t4) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 t3 < S.prime /\
as_nat h1 t4 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = S.fmul x1 x2 in
let t1_s = S.fmul y1 y2 in
let t2_s = S.fmul z1 z2 in
let t3_s = S.fadd x1 y1 in
let t4_s = S.fadd x2 y2 in
let t3_s = S.fmul t3_s t4_s in
let t4_s = S.fadd t0_s t1_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 t3 == t3_s /\
fmont_as_nat h1 t4 == t4_s))
let point_add_1 t0 t1 t2 t3 t4 p q =
let x1, y1, z1 = getx p, gety p, getz p in
let x2, y2, z2 = getx q, gety q, getz q in
fmul t0 x1 x2;
fmul t1 y1 y2;
fmul t2 z1 z2;
fadd t3 x1 y1;
fadd t4 x2 y2;
fmul t3 t3 t4;
fadd t4 t0 t1
inline_for_extraction noextract
val point_add_2 (t1 t2 t3 t4 t5:felem) (p q:point) : Stack unit
(requires fun h ->
live h t1 /\ live h t2 /\ live h t3 /\ live h t4 /\ live h t5 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc t1; loc t2; loc t3; loc t4; loc t5 ] /\
eq_or_disjoint p q /\ disjoint p t1 /\ disjoint p t2 /\
disjoint p t3 /\ disjoint p t4 /\ disjoint p t5 /\
disjoint q t1 /\ disjoint q t2 /\ disjoint q t3 /\
disjoint q t4 /\ disjoint q t5 /\
point_inv h p /\ point_inv h q /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t3 < S.prime /\ as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc t3 |+| loc t4 |+| loc t5) h0 h1 /\
as_nat h1 t3 < S.prime /\ as_nat h1 t4 < S.prime /\ as_nat h1 t5 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t3_s = fmont_as_nat h0 t3 in
let t4_s = fmont_as_nat h0 t4 in
let t3_s = S.fsub t3_s t4_s in
let t4_s = S.fadd y1 z1 in
let t5_s = S.fadd y2 z2 in
let t4_s = S.fmul t4_s t5_s in
let t5_s = S.fadd t1_s t2_s in
let t4_s = S.fsub t4_s t5_s in
fmont_as_nat h1 t3 == t3_s /\ fmont_as_nat h1 t4 == t4_s /\
fmont_as_nat h1 t5 == t5_s))
let point_add_2 t1 t2 t3 t4 t5 p q =
let y1, z1 = gety p, getz p in
let y2, z2 = gety q, getz q in
fsub t3 t3 t4;
fadd t4 y1 z1;
fadd t5 y2 z2;
fmul t4 t4 t5;
fadd t5 t1 t2;
fsub t4 t4 t5
inline_for_extraction noextract
val point_add_3 (x3 y3 t0 t2:felem) (p q:point) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h t0 /\ live h t2 /\
live h p /\ live h q /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc t0; loc t2 ] /\
eq_or_disjoint p q /\ disjoint p x3 /\ disjoint p y3 /\
disjoint p t0 /\ disjoint p t2 /\ disjoint q x3 /\
disjoint q y3 /\ disjoint q t0 /\ disjoint q t2 /\
point_inv h p /\ point_inv h q /\
as_nat h t0 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\
(let x1, y1, z1 = from_mont_point (as_point_nat h0 p) in
let x2, y2, z2 = from_mont_point (as_point_nat h0 q) in
let t0_s = fmont_as_nat h0 t0 in
let t2_s = fmont_as_nat h0 t2 in
let x3_s = S.fadd x1 z1 in
let y3_s = S.fadd x2 z2 in
let x3_s = S.fmul x3_s y3_s in
let y3_s = S.fadd t0_s t2_s in
let y3_s = S.fsub x3_s y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_3 x3 y3 t0 t2 p q =
let x1, z1 = getx p, getz p in
let x2, z2 = getx q, getz q in
fadd x3 x1 z1;
fadd y3 x2 z2;
fmul x3 x3 y3;
fadd y3 t0 t2;
fsub y3 x3 y3
inline_for_extraction noextract
val point_add_4 (x3 y3 z3 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t1; loc t2 ] /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\ as_nat h y3 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc x3 |+| loc y3 |+| loc z3) h0 h1 /\
as_nat h1 x3 < S.prime /\ as_nat h1 y3 < S.prime /\ as_nat h1 z3 < S.prime /\
(let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let z3_s = S.fmul S.b_coeff t2_s in
let x3_s = S.fsub y3_s z3_s in
let z3_s = S.fadd x3_s x3_s in
let x3_s = S.fadd x3_s z3_s in
let z3_s = S.fsub t1_s x3_s in
let x3_s = S.fadd t1_s x3_s in
let y3_s = S.fmul S.b_coeff y3_s in
fmont_as_nat h1 x3 == x3_s /\ fmont_as_nat h1 y3 == y3_s /\ fmont_as_nat h1 z3 == z3_s))
let point_add_4 x3 y3 z3 t1 t2 =
fmul_by_b_coeff z3 t2;
fsub x3 y3 z3;
fdouble z3 x3;
fadd x3 x3 z3;
fsub z3 t1 x3;
fadd x3 t1 x3;
fmul_by_b_coeff y3 y3
inline_for_extraction noextract
val point_add_5 (x3 y3 z3 t0 t1 t2:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\
LowStar.Monotonic.Buffer.all_disjoint [ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t1 < S.prime /\ as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let y3_s = fmont_as_nat h0 y3 in
let t1_s = S.fadd t2_s t2_s in
let t2_s = S.fadd t1_s t2_s in
let y3_s = S.fsub y3_s t2_s in
let y3_s = S.fsub y3_s t0_s in
let t1_s = S.fadd y3_s y3_s in
fmont_as_nat h1 t1 == t1_s /\ fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s))
let point_add_5 x3 y3 z3 t0 t1 t2 =
fdouble t1 t2;
fadd t2 t1 t2;
fsub y3 y3 t2;
fsub y3 y3 t0;
fdouble t1 y3
inline_for_extraction noextract
val point_add_6 (x3 y3 z3 t0 t1 t2 t4:felem) : Stack unit
(requires fun h ->
live h x3 /\ live h y3 /\ live h z3 /\
live h t0 /\ live h t1 /\ live h t2 /\ live h t4 /\
LowStar.Monotonic.Buffer.all_disjoint
[ loc x3; loc y3; loc z3; loc t0; loc t1; loc t2; loc t4 ] /\
as_nat h y3 < S.prime /\ as_nat h t0 < S.prime /\
as_nat h t1 < S.prime /\ as_nat h t2 < S.prime /\
as_nat h t4 < S.prime)
(ensures fun h0 _ h1 -> modifies (loc y3 |+| loc t0 |+| loc t1 |+| loc t2) h0 h1 /\
as_nat h1 t0 < S.prime /\ as_nat h1 t1 < S.prime /\
as_nat h1 t2 < S.prime /\ as_nat h1 y3 < S.prime /\
(let t0_s = fmont_as_nat h0 t0 in
let t1_s = fmont_as_nat h0 t1 in
let t2_s = fmont_as_nat h0 t2 in
let t4_s = fmont_as_nat h0 t4 in
let y3_s = fmont_as_nat h0 y3 in
let y3_s = S.fadd t1_s y3_s in
let t1_s = S.fadd t0_s t0_s in
let t0_s = S.fadd t1_s t0_s in
let t0_s = S.fsub t0_s t2_s in
let t1_s = S.fmul t4_s y3_s in
let t2_s = S.fmul t0_s y3_s in
fmont_as_nat h1 t0 == t0_s /\ fmont_as_nat h1 t1 == t1_s /\
fmont_as_nat h1 t2 == t2_s /\ fmont_as_nat h1 y3 == y3_s)) | {
"checked_file": "/",
"dependencies": [
"Spec.P256.fst.checked",
"prims.fst.checked",
"LowStar.Monotonic.Buffer.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.P256.Field.fsti.checked",
"Hacl.Impl.P256.Bignum.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.All.fst.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": true,
"source_file": "Hacl.Impl.P256.PointAdd.fst"
} | [
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Field",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Bignum",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": true,
"full_module": "Spec.P256",
"short_module": "S"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256.Point",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.All",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.P256",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Pervasives",
"short_module": null
},
{
"abbrev": false,
"full_module": "Prims",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar",
"short_module": null
}
] | {
"detail_errors": false,
"detail_hint_replay": false,
"initial_fuel": 0,
"initial_ifuel": 0,
"max_fuel": 0,
"max_ifuel": 0,
"no_plugins": false,
"no_smt": false,
"no_tactics": false,
"quake_hi": 1,
"quake_keep": false,
"quake_lo": 1,
"retry": false,
"reuse_hint_for": null,
"smtencoding_elim_box": false,
"smtencoding_l_arith_repr": "boxwrap",
"smtencoding_nl_arith_repr": "boxwrap",
"smtencoding_valid_elim": false,
"smtencoding_valid_intro": true,
"tcnorm": true,
"trivial_pre_for_unannotated_effectful_fns": false,
"z3cliopt": [],
"z3refresh": false,
"z3rlimit": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false |
x3: Hacl.Impl.P256.Bignum.felem ->
y3: Hacl.Impl.P256.Bignum.felem ->
z3: Hacl.Impl.P256.Bignum.felem ->
t0: Hacl.Impl.P256.Bignum.felem ->
t1: Hacl.Impl.P256.Bignum.felem ->
t2: Hacl.Impl.P256.Bignum.felem ->
t4: Hacl.Impl.P256.Bignum.felem
-> FStar.HyperStack.ST.Stack Prims.unit | FStar.HyperStack.ST.Stack | [] | [] | [
"Hacl.Impl.P256.Bignum.felem",
"Hacl.Impl.P256.Field.fmul",
"Prims.unit",
"Hacl.Impl.P256.Field.fsub",
"Hacl.Impl.P256.Field.fadd",
"Hacl.Impl.P256.Field.fdouble"
] | [] | false | true | false | false | false | let point_add_6 x3 y3 z3 t0 t1 t2 t4 =
| fadd y3 t1 y3;
fdouble t1 t0;
fadd t0 t1 t0;
fsub t0 t0 t2;
fmul t1 t4 y3;
fmul t2 t0 y3 | false |
Hacl.Impl.RSAPSS.Padding.fst | Hacl.Impl.RSAPSS.Padding.em_len_t | val em_len_t : a: Spec.Hash.Definitions.fixed_len_alg -> saltLen: Hacl.Impl.RSAPSS.Padding.salt_len_t a -> Type0 | let em_len_t (a:Hash.fixed_len_alg) (saltLen:salt_len_t a) =
emBits:size_t{0 < v emBits /\ Hash.hash_length a + v saltLen + 2 <= S.blocks (v emBits) 8} | {
"file_name": "code/rsapss/Hacl.Impl.RSAPSS.Padding.fst",
"git_rev": "eb1badfa34c70b0bbe0fe24fe0f49fb1295c7872",
"git_url": "https://github.com/project-everest/hacl-star.git",
"project_name": "hacl-star"
} | {
"end_col": 92,
"end_line": 35,
"start_col": 0,
"start_line": 34
} | module Hacl.Impl.RSAPSS.Padding
open FStar.HyperStack
open FStar.HyperStack.ST
open FStar.Mul
open Lib.IntTypes
open Lib.Buffer
open Hacl.Impl.RSAPSS.MGF
module ST = FStar.HyperStack.ST
module LSeq = Lib.Sequence
module Hash = Spec.Agile.Hash
module S = Spec.RSAPSS
module BD = Hacl.Bignum.Definitions
#reset-options "--z3rlimit 50 --fuel 0 --ifuel 0"
inline_for_extraction noextract
let less_than_max_input_length = Spec.Hash.Definitions.less_than_max_input_length
inline_for_extraction noextract
let salt_len_t (a:Hash.fixed_len_alg) =
saltLen:size_t{8 + Hash.hash_length a + v saltLen <= max_size_t /\ (8 + Hash.hash_length a + v saltLen) `less_than_max_input_length` a}
inline_for_extraction noextract
let msg_len_t (a:Hash.fixed_len_alg) =
msgLen:size_t{v msgLen `less_than_max_input_length` a} | {
"checked_file": "/",
"dependencies": [
"Spec.RSAPSS.fst.checked",
"Spec.Hash.Definitions.fst.checked",
"Spec.Agile.Hash.fsti.checked",
"prims.fst.checked",
"Lib.Sequence.fsti.checked",
"Lib.RawIntTypes.fsti.checked",
"Lib.IntTypes.fsti.checked",
"Lib.ByteBuffer.fsti.checked",
"Lib.Buffer.fsti.checked",
"Hacl.Impl.RSAPSS.MGF.fst.checked",
"Hacl.Bignum.Definitions.fst.checked",
"FStar.UInt8.fsti.checked",
"FStar.UInt32.fsti.checked",
"FStar.Pervasives.fsti.checked",
"FStar.Mul.fst.checked",
"FStar.HyperStack.ST.fsti.checked",
"FStar.HyperStack.fst.checked"
],
"interface_file": false,
"source_file": "Hacl.Impl.RSAPSS.Padding.fst"
} | [
{
"abbrev": true,
"full_module": "Hacl.Bignum.Definitions",
"short_module": "BD"
},
{
"abbrev": true,
"full_module": "Spec.RSAPSS",
"short_module": "S"
},
{
"abbrev": true,
"full_module": "Spec.Agile.Hash",
"short_module": "Hash"
},
{
"abbrev": true,
"full_module": "Lib.Sequence",
"short_module": "LSeq"
},
{
"abbrev": true,
"full_module": "FStar.HyperStack.ST",
"short_module": "ST"
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS.MGF",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.Buffer",
"short_module": null
},
{
"abbrev": false,
"full_module": "Lib.IntTypes",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Mul",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack.ST",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.HyperStack",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": false,
"full_module": "Hacl.Impl.RSAPSS",
"short_module": null
},
{
"abbrev": 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": 50,
"z3rlimit_factor": 1,
"z3seed": 0,
"z3smtopt": [],
"z3version": "4.8.5"
} | false | a: Spec.Hash.Definitions.fixed_len_alg -> saltLen: Hacl.Impl.RSAPSS.Padding.salt_len_t a -> Type0 | Prims.Tot | [
"total"
] | [] | [
"Spec.Hash.Definitions.fixed_len_alg",
"Hacl.Impl.RSAPSS.Padding.salt_len_t",
"Lib.IntTypes.size_t",
"Prims.l_and",
"Prims.b2t",
"Prims.op_LessThan",
"Lib.IntTypes.v",
"Lib.IntTypes.U32",
"Lib.IntTypes.PUB",
"Prims.op_LessThanOrEqual",
"Prims.op_Addition",
"Spec.Hash.Definitions.hash_length",
"Spec.RSAPSS.blocks"
] | [] | false | false | false | false | true | let em_len_t (a: Hash.fixed_len_alg) (saltLen: salt_len_t a) =
| emBits: size_t{0 < v emBits /\ Hash.hash_length a + v saltLen + 2 <= S.blocks (v emBits) 8} | false |
|
Pulse.Syntax.Printer.fst | Pulse.Syntax.Printer.ctag_to_string | val ctag_to_string (c:ctag) : string | val ctag_to_string (c:ctag) : string | let ctag_to_string = function
| STT -> "ST"
| STT_Atomic -> "STAtomic"
| STT_Ghost -> "STGhost" | {
"file_name": "lib/steel/pulse/Pulse.Syntax.Printer.fst",
"git_rev": "f984200f79bdc452374ae994a5ca837496476c41",
"git_url": "https://github.com/FStarLang/steel.git",
"project_name": "steel"
} | {
"end_col": 26,
"end_line": 180,
"start_col": 0,
"start_line": 177
} | (*
Copyright 2023 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 Pulse.Syntax.Printer
open FStar.Printf
open Pulse.Syntax.Base
module L = FStar.List.Tot
module T = FStar.Tactics.V2
module Un = FStar.Sealed
module R = FStar.Reflection.V2
let tot_or_ghost_to_string = function
| T.E_Total -> "total"
| T.E_Ghost -> "ghost"
let name_to_string (f:R.name) = String.concat "." f
let dbg_printing : bool = true
// let constant_to_string = function
// | Unit -> "()"
// | Bool true -> "true"
// | Bool false -> "false"
// | Int i -> sprintf "%d" i
let rec universe_to_string (n:nat) (u:universe)
: Tot string (decreases u) =
let open R in
match inspect_universe u with
| Uv_Unk -> "_"
| Uv_Zero -> sprintf "%d" n
| Uv_Succ u -> universe_to_string (n + 1) u
| Uv_BVar x -> if n = 0 then sprintf "%d" x else sprintf "(%d + %d)" x n
| Uv_Max us ->
let r = "(max _)" in
// sprintf "(max %s %s)" (universe_to_string 0 u0) (universe_to_string 0 u1) in
if n = 0 then r else sprintf "%s + %d" r n
| _ -> sprintf "<univ>"
let univ_to_string u = sprintf "u#%s" (universe_to_string 0 u)
let qual_to_string = function
| None -> ""
| Some Implicit -> "#"
let indent (level:string) = level ^ "\t"
let rec collect_binders (until: term' -> bool) (t:term) : list binder & term =
if not (until t.t) then [], t
else (
match t.t with
| Tm_ExistsSL _ b body
| Tm_ForallSL _ b body ->
let bs, t = collect_binders until body in
b::bs, t
| _ -> [], t
)
let rec binder_to_string_paren (b:binder)
: T.Tac string
= sprintf "(%s%s:%s)"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string' "" b.binder_ty)
and term_to_string' (level:string) (t:term)
: T.Tac string
= match t.t with
| Tm_Emp -> "emp"
| Tm_Pure p ->
sprintf "pure (%s)"
(term_to_string' (indent level) p)
| Tm_Star p1 p2 ->
sprintf "%s ** \n%s%s"
(term_to_string' level p1)
level
(term_to_string' level p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
sprintf "(exists* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_ForallSL u b body ->
let bs, body = collect_binders Tm_ForallSL? t in
sprintf "(forall* %s.\n%s%s)"
(T.map binder_to_string_paren bs |> String.concat " ")
level
(term_to_string' (indent level) body)
| Tm_VProp -> "vprop"
| Tm_Inames -> "inames"
| Tm_EmpInames -> "emp_inames"
| Tm_Unknown -> "_"
| Tm_AddInv i is ->
sprintf "add_inv %s %s"
(term_to_string' level i)
(term_to_string' level is)
| Tm_Inv i ->
sprintf "inv %s"
(term_to_string' level i)
| Tm_FStar t ->
T.term_to_string t
let term_to_string t = term_to_string' "" t
let rec binder_to_doc b : T.Tac document =
parens (doc_of_string (T.unseal b.binder_ppname.name)
^^ doc_of_string ":"
^^ term_to_doc b.binder_ty)
and term_to_doc t
: T.Tac document
= match t.t with
| Tm_Emp -> doc_of_string "emp"
| Tm_Pure p -> doc_of_string "pure" ^^ parens (term_to_doc p)
| Tm_Star p1 p2 ->
infix 2 1 (doc_of_string "**")
(term_to_doc p1)
(term_to_doc p2)
| Tm_ExistsSL _ _ _ ->
let bs, body = collect_binders Tm_ExistsSL? t in
parens (doc_of_string "exists*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_ForallSL _ _ _ ->
let bs, body = collect_binders Tm_ForallSL? t in
parens (doc_of_string "forall*" ^/^ (separate (doc_of_string " ") (T.map binder_to_doc bs))
^^ doc_of_string "."
^/^ term_to_doc body)
| Tm_VProp -> doc_of_string "vprop"
| Tm_Inames -> doc_of_string "inames"
| Tm_EmpInames -> doc_of_string "emp_inames"
| Tm_AddInv i is ->
doc_of_string "add_inv" ^/^ parens (term_to_doc i ^^ doc_of_string "," ^^ term_to_doc is)
| Tm_Inv i ->
doc_of_string "inv" ^/^ parens (term_to_doc i)
| Tm_Unknown -> doc_of_string "_"
| Tm_FStar t ->
// Should call term_to_doc when available
doc_of_string (T.term_to_string t)
let binder_to_string (b:binder)
: T.Tac string
= sprintf "%s%s:%s"
(match T.unseal b.binder_attrs with
| [] -> ""
| l -> sprintf "[@@@ %s] " (String.concat ";" (T.map (term_to_string' "") l)))
(T.unseal b.binder_ppname.name)
(term_to_string b.binder_ty) | {
"checked_file": "/",
"dependencies": [
"Pulse.Syntax.Base.fsti.checked",
"prims.fst.checked",
"FStar.Tactics.V2.fst.checked",
"FStar.String.fsti.checked",
"FStar.Sealed.fsti.checked",
"FStar.Reflection.V2.fst.checked",
"FStar.Printf.fst.checked",
"FStar.Pervasives.Native.fst.checked",
"FStar.Pervasives.fsti.checked",
"FStar.List.Tot.fst.checked"
],
"interface_file": true,
"source_file": "Pulse.Syntax.Printer.fst"
} | [
{
"abbrev": true,
"full_module": "FStar.Sealed",
"short_module": "Un"
},
{
"abbrev": true,
"full_module": "FStar.List.Tot",
"short_module": "L"
},
{
"abbrev": false,
"full_module": "FStar.Printf",
"short_module": null
},
{
"abbrev": false,
"full_module": "FStar.Stubs.Pprint",
"short_module": null
},
{
"abbrev": true,
"full_module": "FStar.Tactics.V2",
"short_module": "T"
},
{
"abbrev": true,
"full_module": "FStar.Reflection.V2",
"short_module": "R"
},
{
"abbrev": false,
"full_module": "Pulse.Syntax.Base",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": false,
"full_module": "Pulse.Syntax",
"short_module": null
},
{
"abbrev": 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 | c: Pulse.Syntax.Base.ctag -> Prims.string | Prims.Tot | [
"total"
] | [] | [
"Pulse.Syntax.Base.ctag",
"Prims.string"
] | [] | false | false | false | true | false | let ctag_to_string =
| function
| STT -> "ST"
| STT_Atomic -> "STAtomic"
| STT_Ghost -> "STGhost" | false |